|
Hello everyone, I wanted to ask what is the best way to move a rigidbody with a collider? I have many problems using AddForce or MovePosition so I would like to just use Translate for all the movement. I heard that this is bad for the collision detection and performance but I also heard that it doesn't matter. I would really like a reply because if it's indeed bad to use Translate, then I would have to rewrite everything. Thanks
(comments are locked)
|
|
(comments are locked)
|
|
if you're using a CharacterController then Move() works well. Otherwise you can use Translate but you'll have to handle collisions yourself meaning it won't stop you from moving the object through other objects unless you implement that code yourself. Thanks, I don't use a CharacterController, I use a Box Collider and Translate. I don't need to stop on collision or anything but I do need to call a method on collision and when using kinematic, it doesn't register OnCollisionEnter. Any help with that please?
Apr 27 '11 at 08:43 PM
fninetwo
For OnCollisionEnter to work the object which is entering the collider needs to have a rigidbody attached to it. You could also just use Physics.OverlapSphere every frame to check the area around the object (which only requires a collider) but if you do this with a lot of objects at once it may have a big effect on performance.
Apr 27 '11 at 09:45 PM
Ben Holmes
Thanks, I got it working with a CharacterController. Does it make sense to use a CharacterController with a space ship, though?
Apr 27 '11 at 11:23 PM
fninetwo
if it works for your game then yes. If you have a lot of ships which use CharacterControllers then performance may become an issue and in that case I would suggest using a simpler collider and handling some of the collision/physics yourself.
Apr 27 '11 at 11:41 PM
Ben Holmes
(comments are locked)
|

If you want to use translate, remember to mark the rigidbody as kinematic.