- Home /
Avoid character bouncing off of obstacles
Hello, I'm currently working on a simple platformer game to learn using Unity (since I'm fairly new to this tool and to its scripting, I'm using C# at the moment).
I made a script for character movement and jumping (I prefer making it myself rather than using anything that comes with the software). However, when the character encounters an obstacle it awkwardly bounces off, I'd like to avoid that, just a simple stop on collision. So I'm wondering how to do it, maybe make a check if there is a collision with anything else than the floor and if so, stop movement?
yep liek you said, check for collision, if contact with tag or name of the collider, stop the player, but that might be the hard part to script, it also may be rigidbody thats making him bounce?
Can you be more clear about how your character object is set up? Does your character have a kinematic rigid body? Are you using a physics material? Does your character movement script manipulate the Transform, or does it apply forces?
$$anonymous$$y character isn't kinematic, not using physics material (thought about it but doesn't seem to work for that, maybe you can tell me if there's a way), and my movement script manipulate the Transform. I will try to script it but if there's a simpler way, I'm taking.
The transform-based movement might place your character object inside one of the objects, and if both your character and the object have non-kinematic rigidbodies with colliders, it can result in the objects bouncing off. I would suggest using some other form of movement if you want actual collisions. (Perhaps character controllers would do the trick)
What do you mean by character controllers? Also, the obstacle is kinematic.
Answer by OmarAlhaddad · Feb 11, 2013 at 10:36 AM
You can try using a Character Controller to move your character, add it from Component > Physics > Character Controller
After you add it you can access it by:
CharacterController controller;
void Start() {
controller = GetComponent<CharacterController>();
//..etc
}
void Update() {
controller.Move(/*use your motion Vector3 Here*/);
//..etc
}
Good luck
Your answer
Follow this Question
Related Questions
Avoid character bouncing off of obstacles 0 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Making a bubble level (not a game but work tool) 1 Answer
How to check if an object is colliding with another from another script ? 1 Answer
How to go about having two seperate Game Objects follow eachother? 1 Answer