Hello,
My game involves a capsule that moves 5 units on the z-axis automatically infinitely. When it runs into a wall, I want it to become inactive. However, I don’t know what kind of if-statement to use for when something translates into another.
for further clarification, I’ll show you some script excerpts.
Moving infinitely:
Vector3 moveForward = new Vector3 (0, 0, speed);
transform.Translate (moveForward * Time.deltaTime);
Using this code, it will keep moving forward infinitely because it is being translated at 5 units every time.deltaTime.
However, I still want it to run into the wall as if its colliding using phisics. There is a red wall in its path, and when it runs into the wall, I want it to become inactive:
if(GAMEOBJECT RUNS INTO WALL TAGGED "Obstacle")
{
gameobject.setActive(false);
}
However, I don’t know what to put in that if statement.
Help please?