- Home /
Moving the floor flings First Person Controller 1000m backwards
I have a First Person Controller advancing along a floor. When I get to a certain point I want to move the entire floor and the FPC backwards to a different location.
If I have Moving Platform enabled, the FPC is flung about 1000m backwards when I do this (it took me a while to work out that this bizarre thing was happening!). If I disable Moving Platform it is OK but when I re-enable Moving Platform, the FPC is then flung.
I'm wanting to use moving platforms in the game so don't want to permanently disable it. I've tried the following to no avail:
1) switching MP off and on again (the FPC is flung immediately)
_playerTransform.GetComponent(CharacterMotor).movingPlatform.enabled = true;
2) switching MP off and on after a delay (the FPC is flung when I switch back on)
3) setting platformVelocity to zero (no effect)
_playerTransform.GetComponent(CharacterMotor).movingPlatform.platformVelocity = Vector3(0,0,0);
4) setting character motor velocity to zero (no effect)
_playerTransform.GetComponent(CharacterMotor).movement.velocity = Vector3(0,0,0);
5) setting character motor frame velocity to zero (no effect)
_playerTransform.GetComponent(CharacterMotor).movement.frameVelocity = Vector3(0,0,0);
Can anyone suggest how I do this simple thing - just moving the character and floor to a different location without anything getting flung across the scene.
Thanks!
Answer by icywater · Jan 14, 2012 at 05:20 PM
I already read this thread but it doesn't really answer how to stop the unwanted movement. There must be a variable that is being stored and that I need to set to prevent the flinging effect.
$$anonymous$$y problem isn't the FPC slipping or falling through a platform. It's platform velocity being transferred to the FPC to fling it backwards.
It should be the same. Have you tried the 2D Platfor$$anonymous$$g tut?
Answer by aldonaletto · Jan 15, 2012 at 02:04 PM
You could try a transparent trigger a little larger than the moving area (and childed to it), and turn MovingPlatform.enabled off in OnTriggerEnter, and on again in OnTriggerExit:
function OnTriggerEnter(other: Collider){ if (other.tag == "Player"){ other.GetComponent(CharacterMotor).movingPlatform.enabled = false; } }
function OnTriggerEnter(other: Collider){ if (other.tag == "Player"){ other.GetComponent(CharacterMotor).movingPlatform.enabled = true; } }
How are you moving the platform? I just teleported it to a position 20 units behind in z, and the player followed it without any problem:
transform.position.z -= 20;
I had problems only when the platform was moving and its velocity changed too much - the player was thrown to a long distance in some cases.
I am indeed "teleporting" the platform not animating it. Strange I don't get the same result. $$anonymous$$y player is moving at the time of teleport, but the platform is never animated to move.
Your answer
![](https://koobas.hobune.stream/wayback/20220613062959im_/https://answers.unity.com/themes/thub/images/avi.jpg)