tjheldna Posted May 3, 2012 Share Posted May 3, 2012 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!! Quote Link to comment Share on other sites More sharing options...
Mumbles Posted May 3, 2012 Share Posted May 3, 2012 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; } 1 Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
tjheldna Posted May 3, 2012 Author Share Posted May 3, 2012 Thanks Mumbles. It doesn't have to be exact centre, just round about is fine. can't wait to try it tonight!! Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted May 4, 2012 Share Posted May 4, 2012 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. Quote 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 More sharing options...
tjheldna Posted May 4, 2012 Author Share Posted May 4, 2012 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. Hey Thats not a bad idea, I never thought of doing it that way. Quote Link to comment Share on other sites More sharing options...
tjheldna Posted May 5, 2012 Author Share Posted May 5, 2012 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! Quote Link to comment Share on other sites More sharing options...
DigitalHax Posted May 5, 2012 Share Posted May 5, 2012 Not a problem Always happy to help! I use this technique quite a lot in my coding. Especially in player controllers. Quote 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 More sharing options...
Recommended Posts
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.