How to move an object?
transform.Translate(Vector3.forward * speed* Time.deltaTime);
speed is the float variable.
How to rotate an object?
transform.Rotate(Vector3.up * speed * Time.deltaTime);
speed is the float variable.
add velocity to the rigibody?
GetComponent().velocity = new Vector3(0, 10, 0);
x axis, Y axis, Z axis
How to detect a collision
void OnCollisionEnter(Collision col) {
if(col.gameObject.name == "Player(Clone)"){
score += 100;
print(score);
}}
the if statement inside checks if the object collided with is a certain tag name. the col can be named anything.
Is it better on performance to find a gameobject by name or tag. When should this be called?
Finding a game object with by Tag is better for performance and it should be done in the start and awake function.