- Home /
character controller fall on elevator -help-
the elevator is simple, collider that rises and falls, for an animation. the problem is that when I go to the elevator, the character controller falls to move the elevator up. How achieving the . Character controller. Up by elevators without falling? this is the code with the problem:
#pragma strict
var x :int = 1;
var controller:CharacterController = null;
var rapides : float = 6.0;
var gravedad : float = 20.0;
var velocidadSalto : float = 8.0;
var corriendo = false;
var tiempo : float = 0.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update()
{
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= rapides;
}
//
if(!(x<=0)&&Input.GetButtonDown("Jump")) {
//
moveDirection.y = velocidadSalto;
x--;
}
if(controller.isGrounded) {
x = 1;
}
//
if (Input.GetButtonDown("Run")) {
rapides = 9.0;
corriendo = true;
}
else if (Input.GetButtonUp("Run")) {
rapides = 6.0;
corriendo = false;
}
if(corriendo)
{
tiempo += Time.deltaTime;
}
if(tiempo >= 7)
{
corriendo = false;
rapides = 7;
tiempo = 0;
}
// Apply gravity
moveDirection.y -= gravedad * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
///////////////////////////////////////////////////////////////////
what do you mean it falls without even rising a little.
Please rephrase your question.
ready, my idea to climb without falling, when the elevator starts to rise, the character controller does not rise.
need to see the elevator code. Does the elevator have a collider attached?
if so how is it attached? it should I guess be a box or plane bottom.
is it a rigidbody or simply a collider?
the elevator is a simple collider, controlled by an animation, does not contain any scrip, only loop; up and down.
Answer by Aurelio_hl2 · Jun 07, 2013 at 06:17 PM
I solved my problem with this.
this works on platforms: horizontal, vertical, rotating, diagonal, up and down, animated, everything.
not affect physics, no bounce, no fall. does not affect the performance.
create a new java script with this. added a new tag. -> "movim"
add this script to your character controller, or Rigidbody.
#pragma strict
//for Character Controller, Rigidbody, collider or more.
//you can modify *movim* for what you want.
var dentro : boolean = false;
public var scala : float = 1.0000;
function Start () {
dentro = false;
}
function OnTriggerStay ( plataformas : Collider ){
if(!(dentro) && plataformas.gameObject.tag == "movim"){
this.transform.parent = plataformas.transform.parent;
dentro = true;
//Debug.Log ("In");
}
}
function OnTriggerExit ( plataformas : Collider){
if(plataformas.gameObject.tag == "movim"){
this.transform.parent = null;
dentro = false;
transform.localScale = new Vector3( scala, scala, scala);
//Debug.Log ("out");
}
}
Your answer
Follow this Question
Related Questions
how can i let my player move converse? 0 Answers
How to make the character run in Unity with Kinect? 2 Answers
When I build and run my game my character and objects do not appear in the finished game 1 Answer
How to make a character stop going through the terrain? 0 Answers
Achieved Prone & Crouch, but there is a little question in my mind. (Character Controller) 0 Answers