Added Dohya
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class LightFlicker : MonoBehaviour
|
||||
{
|
||||
public float maximumDim;
|
||||
public float maximumBoost;
|
||||
public float speed;
|
||||
public float strength;
|
||||
|
||||
private bool noFlicker;
|
||||
private Light source;
|
||||
private float initialIntensity;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
maximumDim = 0.2f;
|
||||
maximumBoost = 0.2f;
|
||||
speed = 0.1f;
|
||||
strength = 250;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
source = GetComponent<Light>();
|
||||
initialIntensity = source.intensity;
|
||||
StartCoroutine(Flicker());
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator Flicker()
|
||||
{
|
||||
while (!noFlicker)
|
||||
{
|
||||
source.intensity = Mathf.Lerp(source.intensity, Random.Range(initialIntensity - maximumDim, initialIntensity + maximumBoost), strength * Time.deltaTime);
|
||||
yield return new WaitForSeconds(speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1560e0c42f6e77d429c1440b33c57ccc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 159280
|
||||
packageName: Sci-Fi Construction Kit (Modular)
|
||||
packageVersion: 1.1.0
|
||||
assetPath: Assets/SciFi Warehouse Kit/Demo/Scripts/LightFlicker.cs
|
||||
uploadId: 373385
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MouseComponent : MonoBehaviour
|
||||
{
|
||||
public float mouseSensitivity = 100f;
|
||||
public Transform playerBody;
|
||||
float xRotation = 0f;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
|
||||
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
|
||||
xRotation -= mouseY;
|
||||
xRotation = Mathf.Clamp(xRotation, -90, 90f);
|
||||
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
|
||||
playerBody.Rotate(Vector3.up * mouseX);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bd920a6d4c8a664f87d50801bfee470
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 159280
|
||||
packageName: Sci-Fi Construction Kit (Modular)
|
||||
packageVersion: 1.1.0
|
||||
assetPath: Assets/SciFi Warehouse Kit/Demo/Scripts/MouseComponent.cs
|
||||
uploadId: 373385
|
||||
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class PlayRandomSound : MonoBehaviour {
|
||||
|
||||
public AudioSource randomSound;
|
||||
public AudioClip[] audioSources;
|
||||
|
||||
public int clipDelay = 5;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
StartAudio ();
|
||||
}
|
||||
|
||||
|
||||
void StartAudio()
|
||||
{
|
||||
Invoke ("RandomSoundness", clipDelay);
|
||||
}
|
||||
|
||||
void RandomSoundness()
|
||||
{
|
||||
randomSound.clip = audioSources[Random.Range(0, audioSources.Length)];
|
||||
randomSound.Play ();
|
||||
StartAudio ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa804e3faf03f6e4c8bcc4681f3077fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 159280
|
||||
packageName: Sci-Fi Construction Kit (Modular)
|
||||
packageVersion: 1.1.0
|
||||
assetPath: Assets/SciFi Warehouse Kit/Demo/Scripts/PlayRandomSound.cs
|
||||
uploadId: 373385
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
|
||||
public CharacterController controller;
|
||||
public float speed = 8f;
|
||||
public float gravity = -9.81f;
|
||||
public float jumpHeight = 3f;
|
||||
public Transform groundCheck;
|
||||
public float groundDistance = 0.4f;
|
||||
public LayerMask groundMask;
|
||||
Vector3 velocity;
|
||||
bool isGrounded;
|
||||
|
||||
|
||||
public AudioClip footStepSound;
|
||||
public float footStepDelay;
|
||||
|
||||
private float nextFootstep = 0;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
|
||||
|
||||
if (isGrounded && velocity.y <0)
|
||||
{
|
||||
velocity.y = -2f;
|
||||
}
|
||||
|
||||
float x = Input.GetAxis("Horizontal");
|
||||
float z = Input.GetAxis("Vertical");
|
||||
|
||||
Vector3 motion = transform.right * x + transform.forward * z;
|
||||
controller.Move(motion * speed * Time.deltaTime);
|
||||
|
||||
if(Input.GetButtonDown("Jump") && isGrounded)
|
||||
{
|
||||
velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
|
||||
}
|
||||
|
||||
velocity.y += gravity * Time.deltaTime;
|
||||
controller.Move(velocity * Time.deltaTime);
|
||||
|
||||
if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.W) && isGrounded)
|
||||
{
|
||||
nextFootstep -= Time.deltaTime;
|
||||
if (nextFootstep <= 0)
|
||||
{
|
||||
GetComponent<AudioSource>().PlayOneShot(footStepSound, 0.7f);
|
||||
nextFootstep += footStepDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ab0fc542e6aa6e48bf61987d199042b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 159280
|
||||
packageName: Sci-Fi Construction Kit (Modular)
|
||||
packageVersion: 1.1.0
|
||||
assetPath: Assets/SciFi Warehouse Kit/Demo/Scripts/PlayerMovement.cs
|
||||
uploadId: 373385
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PushPhysics : MonoBehaviour
|
||||
{
|
||||
// this script pushes all rigidbodies that the character touches
|
||||
float pushPower = 2.0f;
|
||||
void OnControllerColliderHit(ControllerColliderHit hit)
|
||||
{
|
||||
Rigidbody body = hit.collider.attachedRigidbody;
|
||||
|
||||
// no rigidbody
|
||||
if (body == null || body.isKinematic)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// We dont want to push objects below us
|
||||
if (hit.moveDirection.y < -0.3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate push direction from move direction,
|
||||
// we only push objects to the sides never up and down
|
||||
Vector3 pushDir = new Vector3(hit.moveDirection.x, 0, hit.moveDirection.z);
|
||||
|
||||
// If you know how fast your character is trying to move,
|
||||
// then you can also multiply the push velocity by that.
|
||||
|
||||
// Apply the push
|
||||
body.linearVelocity = pushDir * pushPower;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0b3d149154e23543992bf2ff78e15ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 159280
|
||||
packageName: Sci-Fi Construction Kit (Modular)
|
||||
packageVersion: 1.1.0
|
||||
assetPath: Assets/SciFi Warehouse Kit/Demo/Scripts/PushPhysics.cs
|
||||
uploadId: 373385
|
||||
Reference in New Issue
Block a user