Stop moving an object after touching another

Software: Away3D 4.x

Hec, Newbie
Posted: 15 May 2014 05:40 PM   Total Posts: 20

Hi,
I have two objects, I would like to move one object and when it touch the other it stop moving whitout entering in the other.

I’m use collission to detect and stop the movement but the object is entering in the other by the distance increament. If I put a force it will push it away but i need to stop exactly touching the other.

BODY1.addEventListener(AWPEvent.COLLISION_ADDEDCollision);

function 
Collision(event:AWPEvent):void 
{
dis
=0;
removeEventListener(Event.ENTER_FRAMEGMove);

 

   

Jillinger, Newbie
Posted: 05 September 2014 07:59 PM   Total Posts: 29   [ # 1 ]

The code you are using should work, otherwise you might be experiencing the same problem I had, when I dropped a small object from a certain height. I think the problem may have to do with the mass of the object - I’m not sure.

However, you could try the ray and see if that works.

body.addEventListener(AWPEvent.RAY_CASTfunc); 
   

Hec, Newbie
Posted: 05 September 2014 08:27 PM   Total Posts: 20   [ # 2 ]

Hi,
Ray doesn’t work I need something like a magnet or a snap on.

   

Jillinger, Newbie
Posted: 06 September 2014 03:28 PM   Total Posts: 29   [ # 3 ]

Sorry to hear neither of the two works. What I usually do when I meet a “roadblock”, is try to find a “workaround”. The best workaround I can think of right now, is to create a mesh (or meshes, based on how complex your object is) for both objects, link the mesh that it is always at the rigid body position, and use the bounding box to detect collisions. You should be able to use ray collision, and you don’t even have to render the meshes.
Go here if you need help with the bounding box collisions.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X