So I have this code :
if (Input.GetKey(KeyCode.I))
{
transform.position = new Vector3(0, 10, 0);
Debug.Log("Executed");
//this isn't what I want, this is only to :
// help other people and do what I originally want, something very similar.
}
And I would like it to instead of going to 0,10,0
I want it to go up 10 than it’s original position.
Atleast know what to do in order
EDIT : Please note that this is gonna be a moving object
Maybe, it helps you:
transform.position += new Vector3(0.0F, 10.0F, 0.0F);
Also, if your GameObject has Rigidbody component, you can do this:
Rigidbody rigidbodyComponent = GetComponent<Rigidbody>();
rigidbodyComponent.AddForce(new Vector3(0.0F, 10.0F, 0.0F));
Read more about Rigidbody in documentation.
To set the position relative to its current position use
transform.Translate(new Vector3(0,10,0));