I’m making a game where player can be teleported to the other face of the platform, the side down of the platform when he pass trough a trigger, actually i’m using this scritp and it worked, but when player is teleported, he loses his movement, he just still keep going up because i’ve chanhed the gravity to -20 to make player go up.
public var player: GameObject;
public var blue_platform : GameObject;
function OnTriggerEnter (hit : Collider){
if (hit.gameObject.tag == "blue_platform"){
var blue_platform : GameObject = GameObject.FindWithTag("blue_platform");
transform.position = blue_platform.transform.position;
transform.Rotate(180,0,0);
GetComponent("player_state_color").gravity = -20;
player.transform.position.y = blue_platform.transform.position.y -10;
}
}
Actually i think player loses controll because of the CharacterController, because when i rotate the player it just rotate the graphics not the CharaterController Collider.
Does anybody know how to rotate the CharacterController too?
You’re rotating the trigger collider. You need to rotate the CharacterController using
CharacterController.transform.Rotate()
If your CC absolutely is the parent of the trigger, you can get that simply using
transform.parent.Rotate
Otherwise you’ll have to store a variable.
Also.
“FindWithTag” only returns the first object found, as you would know if you read the Scripting Reference entry. You already have a link to the platform you landed on - hit.gameObject.
I’ve discovered the problem, there is nothing to do about character controller rotate (its the same logic), but the character controller CollisionFlags.ColidedBelow, i’ve maded an validation that changes the CollidedBelow to CollisionFlags.Above, and when my player is teleported below the platform, it changes the state to CollisionFlags.Above, now its working perfectly.