x


How can I make my physics objects stay frozen (eg in mid-air) until touched by another object?

I have a bunch of cube objects in my scene, they have rigidbodys but are set to isKinematic = true.

When the player touches one of these blocks, I want to 'awaken' this block (set isKinematic = false so the block then responds to physics) and at the same time 'awaken' any other blocks which are touching it.

At first I tried doing this with collision detection but it's very buggy and occasionally doesn't work... so I'm trying to think of a more reliable solution. Since the setup is 2D, I was thinking that perhaps I could cast 4 rays, up down left and right, and if those rays collide with another other 'blocks', awaken them too.

I was wondering a) If there is a faster, more performance friendly way of achieving this and b) Is there a way the blocks can listen for Ray hits from other blocks?

more ▼

asked Oct 18 '10 at 08:45 PM

Disaster gravatar image

Disaster
482 48 57 67

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

1 answer: sort voted first

What's the purpose of these blocks being set to isKinematic = true in the first place?

If it is solely so that they remain still (eg, suspended in the air) without physics acting on them, you can use the Sleep() function instead (put it in their Awake/Start function so that they sleep immediately on loading). This means that as soon as they are touched by an active physics object, they will awaken and begin to act as a normal physics object.

more ▼

answered Oct 18 '10 at 09:32 PM

duck gravatar image

duck ♦♦
41k 92 148 415

This is almost perfect, is there anyway to tell when a rigidbody is then subsequently awoken?

Oct 18 '10 at 09:51 PM Disaster

you could use the OnCollisionEnter function for that, probably!

Oct 18 '10 at 10:10 PM duck ♦♦
(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:

x2492
x1870
x261
x177
x6

asked: Oct 18 '10 at 08:45 PM

Seen: 1777 times

Last Updated: Oct 19 '10 at 12:32 PM