Jump to content

Entity Callbacks


Gilmer
 Share

Recommended Posts

Hello guys..

I'm having two problems in use the EntityCollisionCallback and MessageReceiveCallback. The first problem, is that I'm using to make a shader fx when the car collid with an other entity. Like a shake in the camera, or a fast blur. The problem is that It's getting the terrain collision too, ie, the fx is everytime enabled, and just stop when the car is stopped. Have someway to dont get the collision between the car(entity0) and the terrain(entity1)??

 

I tried make this, but dont worked like I wanted:

 

void _stdcall EntityCollisionCallback( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed ) 
{
if(forceCol<=0 && (int)entity1 != 44282192 && (int)entity1 != 144736320){
	if(speed>10)
		Something();
}
}

 

 

And the other problem, is that as I'm using MessageReceiveCallback too, I was noted, that if I set both, like this code:

 

SetEntityCallback(chassis,(byte*)MessageReceiveCallback,ENTITYCALLBACK_MESSAGERECEIVE);
SetEntityCallback(chassis,(byte*)EntityCollisionCallback,ENTITYCALLBACK_COLLISION);

 

the program is crashs. Now if I just put "MessageReceiveCallback", or "EntityCollisionCallback" work fine. Have some wrong in the use this?

 

thx

Link to comment
Share on other sites

The value of the entity could really be anything when it gets loaded. I believe there is a key that you can read to tell if something is the terrain. I use that when I run my scene loading process. I don't remember what exactly it is. Something like "classname" or something. Use GetEntityKey().

 

You could likewise do the same thing with your "car" or player. Give it an entity key and check those inside your collision event. Personally what I do is wrap all these entities inside a class when I load the scene. Then I can cast these entities to the classes I car about using GetEntityUserData() and if the result is NULL I know it's not the class I care about.

Link to comment
Share on other sites

Your callback functions must use the Windows function protocol (unless you are using BlitzMax) and use the following arguments:

void MessageReceiveCallback(entity:TEntity,name:Byte Ptr,extra:Byte Ptr) "win32"

void CollisionCallback(entity0:TEntity,entity1:TEntity,position:Byte Ptr,normal:Byte Ptr,force:Byte Ptr,speed:Float)

 

If you still have problems, please post a simple example I can run, in a bug report.

My job is to make tools you love, with the features you want, and performance you can't live without.

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...