About Store Forum Documentation Contact



Post Reply 
How to create physics actors?
Author Message
fatcoder Offline
Member

Post: #1
How to create physics actors?
What is the correct way to create and set up a phys actor in a custom object class? Here is what I have so far.

In the create function, I use this to set up the actor.
Code:
actor.create(*obj.phys());
actor.obj(this);

Then in the update function, I use this to keep the actor positioned correctly with the mesh.
Code:
actor.matrix(matrix());

So far this seems to be working. If I try drawing the actor, it draws in the correct position with my mesh.

However if I try to create the phys body using any tool other than "Create from Mesh (as Mesh)" (for example, "Create from Mesh (as Convex)" or "Add Box"), then the phys actor doesn't work properly in my game. When my character bumps into the actor, the character is "bounced" very high up into the air.

If I load the object in as a STATIC object (instead of using my custom class), then it works fine then with any phys body. Therefore the Static object class must be doing something different with the phys actor.

Can anyone show me how to set up a phys actor correctly in a custom class?

Perhaps I've found the solution to this problem. Does it have anything to do with the density of the actor. I have tried setting the density to 0 and it has stopped the character from bouncing off the actor. Is this how the Static object class handles it?
(This post was last modified: 07-08-2010 04:52 AM by fatcoder.)
07-08-2010 04:39 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: How to create physics actors?
what kind of actor do you want to have?
there are 3 kinds,
dynamic, kinematic, static, please check to docs about them (physical body and actor)
07-08-2010 12:07 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #3
RE: How to create physics actors?
The actor is for a building in the game world. Therefore the characters should not be able to move it by pushing against it. However the building can be moved or removed at run time as needed by the game rules. Therefore, I believe it should be a static actor. I assume a static actor is created by just setting its density to 0 when created.
07-08-2010 02:41 PM
Find all posts by this user Quote this message in a reply
Post Reply