How would someone go about creating multiple triggers in one script
I've been trying to learn more about Vectors, Positions, and Triggers and I was wondering if there is anyway to add multiple triggers under 1 "OnTriggerEnter2D"
void SetCamPosition()
{
camera.transform.position = camPosition;
}
void OnTriggerEnter2D (Collider2D other)
{
if (other.transform.name == "TriggerUp")
camPosition.y += 57;
if (other.transform.name == "TriggerDown")
camPosition.y -= 57;
if (other.transform.name == "TriggerLeft")
camPosition.x -= 57;
if (other.transform.name == "TriggerRight")
camPosition.x += 57;
SetCamPosition ();
Debug.Log ("Triggered");
}
This is just a rough draft but basically I have 4 sides surrounding the Camera view and on trigger up It moves the camera 57 units up and so forth the other sides.
I can get the TriggerUp to work but as soon as I try adding other components it just stops working
Your answer
Follow this Question
Related Questions
Trying to Generate Different Random Values for Position of Game Object Instances [C#] 1 Answer
Need help with multiple updating transform positions 2 Answers
Terrain height -> loosing Players GO childs 0 Answers
why when putting a cube prefab as a child of another moving object it change the cubes scale !!! 0 Answers
Need help with this code? thanks. 2 Answers