Question by
Pablosaitua · Jun 08, 2017 at 08:26 AM ·
scripting beginnerscriptingproblemenable and disable script
Trying to enable a camera shake script on a FPS on Collition with a Cube.
Hi, I am trying to enable a camera shake script on a FPS on Collition with a Cube. I tagged the Cube with ShakeTrigger. The name of the script that shakes the camera is CameraShake. I got so far building my script. The CameraShake script is turned of when turning on the game.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class EnableComponent : MonoBehaviour {
private CameraShake cameraShake;
void Start()
{
cameraShake = GetComponent<CameraShake>();
}
void OnCollisionEnter(Collision colliion)
{
if (gameObject.tag == "ShakeTrigger")
{
cameraShake.enabled = !cameraShake.enabled;
}
}
}
Obviously I am still a bit new at this. ;)
Comment