Jump to content

Two physics related questions


tjheldna
 Share

Recommended Posts

Hi All,

 

I just have a few questions about how to do a couple of things in the engine.

 

1. I have some collectable coins that shoot from a broken prop, thats all cool but I always want the body to be facing upright as they fly out and bounce. Is that possible?

 

2. How do I get the centre XYZ of a phyics body?

 

Many Thanks!!

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

1. Set the body's angle with the RotateEntity command before adding the "throwing" force. It will keep this orientation until it hits something.

 

2. Get the Entity's AABB. The mid point of each axis should either be the exact centre, or so close no one will know the difference

 

(C/C++)
TVec3 GetMidpoint(const TEntity &Entity)
{
TVec3 OutputVector;
TVec6 AABB = GetEntityAABB(Entity);
OutputVector.X = ((AABB.X1 - AABB.X0) / 2) + AABB.X0;
OutputVector.Y = ((AABB.Y1 - AABB.Y0) / 2) + AABB.Y0;
OutputVector.Z = ((AABB.Z1 - AABB.Z0) / 2) + AABB.Z0;
return OutputVector;
}

  • Upvote 1

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

You could always have a physics object that hits the ground, have a separate coin mesh that doesn't have the objects rotation. Only position.

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Link to comment
Share on other sites

The solution of creating a physics body and positioning the coin to the body worked a treat! Thanks DigitalHex! The code for object centre is great to, I have a number of instances where I need that.

 

I must say as a new comer to this engine, it is so easy to code in compared to others. Really loving this engine.

 

Thanks again guys!

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

Not a problem ;) Always happy to help!

 

 

 

I use this technique quite a lot in my coding. Especially in player controllers.

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

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