Physics collisions

Is there a way to make a physics object register a collision when the object is just inside the bounds, instead of only entry and exit? [import]uid: 147322 topic_id: 27666 reply_id: 327666[/import]

You’d use a flag, when another object entered the bounds of the sensor you could have a variable like inSensor = true, then set it to false when the collision event ends :slight_smile: [import]uid: 52491 topic_id: 27666 reply_id: 112266[/import]

Would that work if you were processing hundreds of collisions per second? And where would you add it? In the event.other?

By the way, look closely at my profile picture just as you enter (or reload) the topic. [import]uid: 147322 topic_id: 27666 reply_id: 112297[/import]

I don’t notice anything with your picture - what am I looking for? (It may be browser related?)

As to would it work if processing hundreds of collisions per second, it would work as well as anything else would - although it may help to know more about what you are working on. (I’m trying to imagine a time you’d need a sensor that had hundreds of collisions a second and can only picture a sand/liquid simulation of some sort?) [import]uid: 52491 topic_id: 27666 reply_id: 112472[/import]

Ok, here it is:

  1. Trying to make a ‘gravity radius’, as you showed how you might do it before.
  2. Using that part where I said ‘thousands of little balls falling onto the screen’.
  3. I am trying to get the balls to when I touched the screen, add a ‘gravity radius’ at that point so they all are pulled toward it.
  4. I’ve got it good, only they only get pulled towards it when they enter or exit the radius.
  5. Look at my little avatar’s eyes. I only got it to do it once, not repeated, but it still does it.
  6. Would you, perhaps, do something like this?
    When they collide, add a timer to
    a. check if they are in the radius, and
    b. apply force if they are.
    If they aren’t in the radius, remove the timer?

How would I do that?

binc [import]uid: 147322 topic_id: 27666 reply_id: 112487[/import]

I would apply force as soon as they entered the radius, no timer. Unless you need them to follow the touch in which case yes, I would suggest a timer removed when they leave the sensor area as you said. [import]uid: 52491 topic_id: 27666 reply_id: 112493[/import]

The problem is that they only apply force on entry/exit. How would I get it to apply force without stopping? [import]uid: 147322 topic_id: 27666 reply_id: 112500[/import]

If you want to apply force more than once while it is within the sensor area then yes you’d use a timer - but just keep in mind that it stacks. [import]uid: 52491 topic_id: 27666 reply_id: 112616[/import]

See, the thing is if you don’t apply force with a timer, (which I don’t know how to do) it makes a movement from one side to another and back and forth over and over, because it is leaving and entering, because of the ‘collision’ listener. [import]uid: 147322 topic_id: 27666 reply_id: 112650[/import]

Can you only apply it when it enters the sensor radius, then? [import]uid: 52491 topic_id: 27666 reply_id: 112741[/import]

Well, I want it to have an effect like gravity. I’ve found it works if you recreate and recreate and recreate your radius, but surely there’s a better way to do it? [import]uid: 147322 topic_id: 27666 reply_id: 112765[/import]

If you want it like gravity with the center of the radius as the center of gravity then your original idea of using timers makes a lot of sense, although if recreating it works for you and you then there is no harm in doing that either - it may prove less intensive on memory usage than running a bunch of timers.

Peach :slight_smile: [import]uid: 52491 topic_id: 27666 reply_id: 112859[/import]

Thanks! I’ll try it. [import]uid: 147322 topic_id: 27666 reply_id: 112889[/import]