- Home /
Problem with rotation of objects
OK, I am trying to make a limited movement that depends on the rotation of the wall to make the player cover on a wall and it work pretty good, but it only works good if the wall is on a certain rotation, here is part of my script:
function Update(){
if(incover == true){
transform.position.x = limitmovement;
}
}
function OnTriggerStay(other : Collider){
if(other.transform.tag == "Walls"){
if(Input.GetKeyDown("e")){
limitmovement = other.transform.position.x;
transform.rotation = other.transform.rotation;
incover = true;
}
}
}
It works good but when you change the wall rotation or players rotation the limit position and the position of the player is different of what I want so, how can I combine the player position and rotation to make it work well?
Edit
I don't know if this is something normal of Unity or not but the problem seems to be that when I rotate any object it doesn't matter if is local or global the axis position changes example: rotation x = 0 position(forward) = x,rotation x = 90 position(forward) = z. This maybe has to be something with this.
Please I need help with this,feel free to do any comment, idea, reply or answer, I will appreciate it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613125711im_/https://answers.unity.com/themes/thub/images/avi.jpg)