Jump to content

Problem with collision callback


Uberman
 Share

Recommended Posts

I posted that b/c i changed it back. I removed the pointers at 'entity0' and 'entity1' and the above line is still throwing the error.

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Link to comment
Share on other sites

This works

 

 

class MyClass
{
TEntity _this;

static void _stdcall _onCollision( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed );

public:
MyClass();
};


MyClass::MyClass()
{
// create the entity _this
// _this = CreateXXXXX


// register for collison detection
SetEntityUserData( _this, reinterpret_cast<BP>(this) );
SetEntityCallback( _this, reinterpret_cast<BP>(_onCollision), ENTITYCALLBACK_COLLISION );
}

void MyClass::_onCollision( TEntity us, TEntity them, byte* position, byte* normal, byte* force, flt speed )
{
MyClass* pThis = reinterpret_cast<MyClass*>(GetEntityUserData(us)) ;
if( pThis == 0)
		 return;

// Do your thing on collision
// You are pThis
}

  • Upvote 1

Roland Strålberg
Website: https://rstralberg.com

Link to comment
Share on other sites

my OnColl function is only calling the collision of the last instance of the class that was created. so if one entity collides with another, if another instance of the entity was created after this one, then only the last entity collision function will be called. so another example,

object_1 object_2 object_3 was created using class A. rock_1 rock_2 rock_3 was created using class b. when rock_ rock_2 rock_3 collide with object_2, the collisions for object_3 is called and executed. this is done using ricks method. is this happening b/c of polymorphism? i don't see how. anyone got any ideas?

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Link to comment
Share on other sites

I fixed the issue. I needed to set my block object as a pointer and pass the pointer to the list that stored all my block objects.

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Link to comment
Share on other sites

  • 4 months later...

hey rick. Does this work with LE3 as well or what are you doing for your collision handling in Leadwerks 3?

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...