Hi,
so i have Player in 3D game and i made platform that moves in X axis with this script:
var Speed : float = 2;
var NewPos : Vector3;
private var StartPos : Vector3;
private var GTime : float;
private var IsThere : boolean;
function Start () {
StartPos = transform.position;
}
function Update () {
if (GTime <= 1 && !IsThere) { GTime += Speed * Time.deltaTime; }
if (GTime >= 1) { IsThere = true; }
if (GTime >= 0 && IsThere) { GTime -= Speed * Time.deltaTime; }
if (GTime <= 0) { IsThere = false; }
transform.position.x = Mathf.Lerp (StartPos.x,NewPos.x,GTime);
transform.position.y = Mathf.Lerp (StartPos.y,NewPos.y,GTime);
transform.position.z = Mathf.Lerp (StartPos.z,NewPos.z,GTime);
}
but my player dont follow it when he is on it,how do i fix it?
I am completely noob here so I dont know how to do this first solution, i know how to parent,but this unparent when they jump dont know if u could help me with this it would be great.
– misko96transform.parent = null; Have that line either in your jump code, or maybe in your OnCollisionExit. Keep in mind if a platform is moving quickly and the player jumps they won't gain the momentum and the platform will fly out from right underneath their feet!
– MakinStuffLookGoodI did but still no changes, probably bcs I failed something, I started unity few weeks ago and really dont know anything about scripting.
– misko96