- Home /
moving platform jumping and then continuing it's path
Hi. I am working on a 3rd person marble game and I want the marble to be able to go on to moving platforms. I made a var that checks if the player has collided so that the movement sequence is initialized. but when I go on the platform, it jumps over about 25 m and then continues it's animation sequence. My code looks like this :
var Speed : float; var intPos : Vector3; var moveAmount : Vector3; var isTriggeredByCollision : boolean = false; private var isMoving : boolean = false;
function Start () { intPos = transform.position; } function FixedUpdate () { if(isMoving) { transform.position.x = intPos.x + Mathf.PingPong(Time.time Speed, moveAmount.x); transform.position.y = intPos.y + Mathf.PingPong(Time.time Speed, moveAmount.y); transform.position.z = intPos.z + Mathf.PingPong(Time.time * Speed, moveAmount.z); } } function OnCollisionEnter(col : Collision) { if(col.gameObject.tag == "Player" && isTriggeredByCollision) { isMoving = true; }
}
Your answer
Follow this Question
Related Questions
CharacterController falls through or slips off moving platforms 2.0 2 Answers
What is the easiest way to push a character controller with a moving platform? 0 Answers
Problem with moving (animated) platforms. need script to keep player object on 1 Answer
Moving Platform 1 Answer
Platforms again.. Working but.. 0 Answers