in my game I want to make a platform (cube) move between two objects, bouncing back and forth at at all times so my first person controller can get on it and move across to a different set of land can i please have a script to make it do that i havent figured one out yet. Thank you
Just make a script to move the platform - the First Person Controller prefab already can ride moving platforms: if you jump over a moving platform, the FPC will move with it as you would expect.
There are several alternatives to create a moving platform - this is one of the easiest ways:
var amplitude: float = 5; // platform excursion (+/- 5 units, in this case)
var speed: float = 0.2; // movements per second
var direction: Vector3 = Vector3.forward; // direction relative to the platform
private var p0: Vector3;
function Start(){
p0 = transform.position;
while (true){
// convert direction to local space
var dir = transform.TransformDirection(direction);
// set platform position:
transform.position = p0+amplitude*dir*Mathf.Sin(6.28*speed*Time.time);
yield; // let Unity free till the next frame
}
}
Create a Unity’s cube, adjust its dimensions and add this script to it, then tweak the parameters speed, amplitude and direction - the last one is a vector that defines the movement direction relative to the platform.
If you don’t like iTween, use an AnimationCurve. The result of Evaluate will be between 0 an 1, you can use it in a Lerp.
whats the 6.28 in there for?