- Home /
OP resolved issue.
Script Stopped Working - Walking on Walls
Hello all! I got a weird bug here...
I was using this code "Walking on Walls", and it was working just fine. The character rotates and "sticks" to the wall.
On the next day, the script wasn't working anymore! The character rotates, align to wall's normal (and should stay in this position to walk on the wall), but when it finish rotating, the character returns to it's original rotation, and then sticks to the wall.
Can anyone help me? I did not change the code in the meanwhile. Actually, I did not created any other code, tags, layers, prefabs or names that could possibly interfere, I was just creating the level.
did you update unity? that can cause a problem. post your codes you think are interfering.
Nope.. I didn't update Unity. And I don't have other codes interfering actually. HEELP! =(
I found where the bug is, but I still can't fix it.
function JumpToWall(point: Vector3, normal: Vector3){
// jump to wall
jumping = true; // signal it's jumping to wall
rigidbody.is$$anonymous$$inematic = true; // disable physics while jumping
var orgPos = transform.position;
var orgRot = transform.rotation;
var dstPos = point + normal * (distGround + 0.5); // will jump to 0.5 above wall
var myForward = Vector3.Cross(transform.right, normal);
var dstRot = Quaternion.LookRotation(myForward, normal);
for (var t: float = 0.0; t < 1.0; ){
t += Time.deltaTime;
transform.position = Vector3.Lerp(orgPos, dstPos, t);
transform.rotation = Quaternion.Slerp(orgRot, dstRot, t);
// Debug.Log(t);
yield; // return here next frame
}
myNormal = normal; // update myNormal
rigidbody.is$$anonymous$$inematic = false; // enable physics
jumping = false; // jumping to wall finished
}
The bug is when transform.rotation gets from the orgRot to the dstRot. When it happens, my character gets back to original rotation and sticks to the wall.
Answer by ViktorEisenmann · Sep 24, 2013 at 01:51 AM
Found the bug! I was using Mouse Look. The weird thing is... it was working fine few days ago...
Follow this Question
Related Questions
Basic movement. Walking on walls. 8 Answers
CharacterController, Move toward mouse 1 Answer
How do i rotate based on direction character is moving in 1 Answer
Align plane to normal but keep Y-axis intact 1 Answer
8-Axis 3D Top Down Movement 1 Answer