Transform.Parent Rotation

Hey Crew,

I have made an elevated platform that moves the player up and down,

the issue i have is that when the player lands on the elevated platform; the players rotation is changed to match the platform, and then resets to the players rotation when they step off the platform.

How can I stop the players roation from changing?

void Start () {
_startPos = transform.position;
}

void Update () {
transform.position = _startPos + new Vector3( 0.0f,(Mathf.Sin(Time.time*speed))*height, 0.0f);
}

void OnTriggerEnter(Collider other)
{
if(other.tag==“Player”)
other.transform.parent=transform;
}

void OnTriggerExit(Collider other)
{
if(other.tag==“Player”)
other.transform.parent=null;
}

Thanks

Check this out:) : Unity - Scripting API: Transform.SetParent

void Start () {
_startPos = transform.position;
}

void Update () {
transform.position = _startPos + new Vector3( 0.0f,(Mathf.Sin(Time.time*speed))*height, 0.0f);
}

void OnTriggerEnter(Collider other)
{
if(other.tag=="Player")
//other.transform.parent=transform;
other.transform.SetParent(this.gameObject.transform, false);
}

void OnTriggerExit(Collider other)
{
if(other.tag=="Player")
other.transform.parent=null;
}

I think he actually wants “true”. I didn’t want to ruin all of the answers lol. I could be wrong, technically he didn’t specify if he meant “prevent it changing before or after”, I just assumed he meant when landing on the platform. :slight_smile:

@methos5k it’s all good. we’ll let him decide if it’s true or false!

lol, indeed. We’ll see what he says :slight_smile: