- Home /
transform.TransformDirection problem .
function Update () {
moveMent_Direction=Vector3.zero;
if(char_Controller.isGrounded){
anim_Controller.SetBool("jump",false);
if(Input.GetAxis("Vertical")>0.1){
currentSpeed=Input.GetAxis("Vertical")*topSpeed;
anim_Controller.SetFloat("speed",currentSpeed);
moveMent_Direction= new Vector3(Input.GetAxis("Horizontal"),0,currentSpeed);
}else{
currentSpeed=0.0f;
moveMent_Direction=Vector3(0,0,currentSpeed);
anim_Controller.SetFloat("speed",currentSpeed);
}
if(Input.GetKey("1")){
// moveMent_Direction.y=7;
check_Ob();
anim_Controller.SetBool("jump",true);
}
}
moveMent_Direction=transform.TransformDirection(moveMent_Direction);
moveMent_Direction.y-=10*Time.deltaTime;
char_Controller.Move(moveMent_Direction*Time.deltaTime);
}
Problem is , if i add moveMent_Direction=transform.TransformDirection(moveMent_Direction); , then my character don't move.and stays at that same position . And one thing more , You notice that i am making moveMent_Direction=Vector3.zero; moneMent_Direction to 0 at every update call . Because of this , gravity functionality if affecting . Character goes down very slowly . Please tell me what i am doing wrong .
Using Debug.Log , I found that it is changing my z component of the move$$anonymous$$ent_Direction vector i.e. (0,0,3) ----> (0,-3,0) .
When i imported that character , i need to rotate it 90 degree around x . because it is in laid position . If i make this rotation to 0 then it moves forward but in laid position.
What is this all happening ????