- Home /
Player goes straight through cube
As the the title says, I'm moving a player on a 2D sidescroller. I can jump and move left and right as well as jump. The player has a rigidbody and character controller attached to it. I then have one cube to test collision. The player goes through the cube, but can sit on top of it if you jump on it. the cube has a box collider and a rigidbody. Can any one solve my problem? If you don't get what I mean, here's a video to it: http://www.youtube.com/watch?v=Cegx8BOYxbk&feature=youtu.be. If you need more information on my problem, just ask.
Can you give us the script you use to move your cube?
How are you controlling the left/right movement of the player? Directly via transform.position? If so, the player will ignore any collision.
What are you using to move your char? Char Controller script or translate?
// amount to move player amtTo$$anonymous$$oveH = (playerspeed Input.GetAxis("Horizontal")) Time.deltaTime; //move player horizontally transform.Translate(Vector3.right * amtTo$$anonymous$$oveH);
Then I use the character Controller to jump. The Jump is moveDirection
Thats why. Youre using translate to move the char left and right, use the char controller to do that as well. It ignores collision when using translate.
Answer by Piflik · May 07, 2012 at 08:17 PM
transform.Translate ignores collisions. Use CharacterControler.Move() or CharacterControler.SimpleMove() instead.
Your answer
Follow this Question
Related Questions
Parent Object 0 Answers
Rigidbody collision/interaction 2 Answers
Player colliding with pickable object 0 Answers
Issues Making Character Move With Rigidbody 1 Answer
Player's hands passing through opponent while punching 0 Answers