In my game i want to make a platform, and when my FPC steps on it, he flies up in the air, i’ve tried some codes but I cant figure it out, if anyone knows how to do this that’d be great. Thanks!
I suppose you want the platform to go up for a hosrt distance and extremely fast, so it can throw the player. Physic is probably not the best way to go as it would probably leave the player behind. I suggest you use a collider on the platform only to detect when the player step on it, then parent the player to the platform, make it go up, unparent and finally add a force upward to the player. A big one. You might have to save the player’s velocity when he steps one the platform.
If you’re using the First Person Controller prefab, create a trigger, child it to the platform and add this script to it:
var speed: float = 50; function OnTriggerEnter(other: Collider){ var cMotor: CharacterMotor = other.GetComponent(CharacterMotor); if (cMotor){ cMotor.SetVelocity(Vector3.up * speed); } }
This does not move the platform, but will shoot the FPC up at speed meters per second.