- Home /
Question by
asif_17 · Oct 05, 2013 at 12:37 PM ·
Mover Player With seesaw
hi
i am fasing problem kindly give me an idea...
problem is i have to move player with seesaw... when seesaw moves if player is standing on seesaw that should also move with seesaw...
seesaw is moving with this scripts attached with seesaw...
void OnMouseDown()
{
screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);
offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
}
void OnMouseDrag()
{
Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, screenPoint.y, screenPoint.z);
Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) ;
transform.position = curPosition;
}
kindly give me your idea how player will move with seesaw...
Thanks
jumps.jpg
(238.3 kB)
Comment
Answer by Matt-Face · Dec 24, 2013 at 03:20 AM
hi,
you can change the player's parent to be the seesaw whilst the player is on it... see the below example:
playerTransform.parent = colliderGameObject.transform;
Your answer
Follow this Question
Related Questions
Ref modifier 1 Answer
A node in a childnode? 1 Answer
Why won't this compile? 1 Answer
Can't get an object to look at object. 1 Answer
C# Coding error 1 Answer