- Home /
How to precisely control a character through scripts while still using unity collisions?
Every time I try to learn unity I hit the same block. I want to have total control over my player characters in scripts. I want to be able to use Unity's built in collision detection and response without having to deal with dynamic rigidbodies. Kinematic rigidbodies seem like they offer what I want but I can't seem to get collision working with those. When building games I usually move things using a linearVelocity Vector2 that I have complete control over, allowing for me to create custom physics for my game but I'm having so much trouble trying to achieve this in Unity. Should I use kinematic bodies? If so, how do I solve the collision problem?
Note: I'm only interested in 2D games so I can't use the character controller as far as I can tell.
Please help. I really want to get into Unity but I just can't stand having to use awkward physics to control everything.
Answer by lassade · Dec 14, 2017 at 10:42 PM
To achieve linear motion you only have to use Physics2D velocity, turn off gravity and apply your own gravity acceleration (or maybe a velocity?). Only use kinematic bodies for moving platforms and such, your player should not be kinematic. Moving the player from point A to point B is no a matter of a velocity during a single frame for this use FixedUpdate function. Collisions should work no problem
Do I missing something?
Thanks for the reply. So you're saying that I should use a dynamic rigidbody and manually set the velocity of the rigidbody? How exactly would I do that, just "rigidBody.velocity = new Vector2(0,0)"?
EDIT: Okay I tried that and it works perfectly so far. Thank you so much.
Your answer
Follow this Question
Related Questions
Character colliding with itself when touching a particular object 1 Answer
How can I make the health points constantly go down? 1 Answer
Updated Unity, 2D Colliders not working. OnTriggerEnter2D not working 0 Answers
Limit player speed (2D) 3 Answers
How do I make an object rotate gradually using Rigidbody2D.MoveRotation() 3 Answers