Silly question, how do I test the y value of the object the script is attached to?
Would I just use if (y < -20)?
EDIT: same thing for setting velocity value, would I use a this.y or this.velocity or something of the like?
Silly question, how do I test the y value of the object the script is attached to?
Would I just use if (y < -20)?
EDIT: same thing for setting velocity value, would I use a this.y or this.velocity or something of the like?
Tried y, this.y, and player.y, none have worked. This is a pretty simple task, I just don’t know how to do it. ![]()
Should be able to use something like:
gameObject.transform.position.y
I don’t know if the “gameObject” part is needed.
Thanks so much, that did it. What about velocity, I don’t see it as a variable of the Transform class…
I think for velocity you need something like a rigid body component attached to the object, unless you want to calculate velocity yourself (by checking the change in position and time elapsed).
If there is a rigid body attached, you should be able to access via:
rigidbody.velocity.y