- Home /
Question by
zerokk123 · May 02, 2012 at 12:36 PM ·
gameobjecttransformposition
Can i transform the position of an object to another object?
Just wanna know if it can , it would be helpful!
if yes , please write me a example so i can understand=D. thanks you.
Comment
Answer by syclamoth · May 02, 2012 at 12:38 PM
Easy enough- just put this script on your object, and then when you want the object to move, call 'SnapPosition':
public Transform targetPos;
public void SnapPosition()
{
transform.position = targetPos.position;
// Add a line for rotation if you need to, it's basically the same
}
void Update()
{
// Usage example:
if(Input.GetButtonDown("Fire1"))
{
SnapPosition();
}
}
Your answer
Follow this Question
Related Questions
How to move a gameObject without affecting its childrens' positions? 2 Answers
I want to move a cube with rotation but I find this problem 1 Answer
Why is my variable updating when it shouldn't? 1 Answer
How to assign x and y transform values of an gameobject to user defined variables? 1 Answer
Force object position 1 Answer