#position

1 messages · Page 1 of 1 (latest)

obsidian grove
#

.

#

@fossil raft so basically if you want to move a different object you have to get its transform

#

Theres several ways to reference it, Im not sure which you need

fossil raft
#

like this:
transform.Translate(0, 0, (Position of the other object) - 5)

obsidian grove
#

No, Translate is used for moving the object by a given distance, not setting the position

#

if you set position, you just

transform.position = vector3 something something

fossil raft
#

yeah but i want the object to stop if the contacted object stops

#

how can i do that

obsidian grove
#

yeah you just need to set the position every update

#

so it would be like

fossil raft
#

ah ok

obsidian grove
#
transform.position = new Vector3(otherTransform.position.x, transform.position.y, transform.position.z)
fossil raft
#

so if the other object = player would it be like this?
transform.position = new Vector3(transform.position.x, transform.position.y, player.position.z - 5f);

obsidian grove
#

you mean player being a variable storing the other object's transform then yes

#

if its the gameobject then player.GetComponent<Transform>().position. z

fossil raft
#

ok thx

#

do you have time to help me with something else?