- Home /
How can I make a platform move only when the player is on it?
I have a cube that I use as a mobile platform, but would like it to move only when the player was on top of it. How can I do this?
Answer by Klaus-Eiperle · Aug 05, 2014 at 09:44 AM
Hi,
I think when you use an Trigger, the player would fall through the platform. So I would prefer to use OnCollisionStay.
public class MovePlatform : MonoBehaviour {
void OnCollisionStay(Collision collisionInfo) {
if (collisionInfo.gameObject.tag == "Player") {
// Move your platform here
}
}
}
All the best, Klaus
thanks for the answer, i will try to do this and see if work
sorry for be so slow to answer, your suggestion work, thank you very much my friend :)
Your answer
Follow this Question
Related Questions
Check which side of a cube my player collided with 1 Answer
Move object with mouse without passing through colliders 0 Answers
Collision detections under specific conditions 0 Answers
How to make an object 'push' my character out of the way upon collision? 0 Answers
How to get character movement done with box collider 2d? 2 Answers