x


Collision and physics: asteroid

Hi there!

So, I'm now programing the collision system for my game, and when my ship hits a asteroid two things happen:

  1. I loose control of my ship;
  2. The asteroid goes flying to a place very far away;

First how can I prevent the loss of control of my ship, and second, how can I prevent the asteroid from going to "a place very far away", and instead just divert slightly its course?

The ship has a rigidbody with a mass of 1, and a capsule collider, while the asteroid (a cube, at this moment) has a rigidbody with a mass of 0.5 and a cube collider. Both rigidbodies are affected by gravity (which is 0 in this scene). At this moment the only scripts I've is the one to control the ship, the camera script, and nothing more.

So, how can I fix this?

Thanks in advance.

João Borrego

more ▼

asked Jul 31, 2012 at 03:06 PM

JPB18 gravatar image

JPB18
155 76 70 75

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Well maybe try to change the mass no? :D

As the doc say for Rigidbody.mass, try not to go above 10, and it's more of a "relative" scale : higher value will move less when hiting lower value and vice versa. So why not try something like 1 for the ship and 2 or more for the asteroid?

For the loss of control, well you can try to play with the Rigidbody.angularDrag, as the doc says "the higher it is, the fastest the rotation will stop". Same thing apply to the "drag", that affect the linear velocity (how fast will the mobile come to a top when moving).

You can also try to play with the Physic Material, changing the bouciness or else...

more ▼

answered Jul 31, 2012 at 03:20 PM

Sirithang gravatar image

Sirithang
101 4 5 7

I guess those tips worked, and are going to be useful in the future! Thanks!

Jul 31, 2012 at 03:30 PM JPB18
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3289
x281
x189
x10

asked: Jul 31, 2012 at 03:06 PM

Seen: 996 times

Last Updated: Jul 31, 2012 at 03:30 PM