Jump to content

AddBodyForceAtPoint?


Von04
 Share

Recommended Posts

Does anyone have an example of AddBodyForceAtPoint to a picked object? I need the force to come from the angle of the camera to the picked object. I also need to do this is c++ and not in Lua. Any help would be appreciated.

3d world studio. 3ds Max 8. GTX 260. Visual Studio 2010. Dual Core 2.6 Mhz processor.

Link to comment
Share on other sites

convert the relevant code from the fpscontroller.lua to c++ ?

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Off the top of my head I would do it like this

 

When you spawn a player or object that you want to shoot later:

 

Put the class in an array eg. make a player class and manage all your players through a player class array. so player[0] points to the first instance of your player class etc.

 

When you spawn a player do this:

SetEntityKey(PlayerMeshEntity, "Player", "playerNumber");  // make playerNumber an actuall number like "1" whatever it will have to increment for every player of object

 

Then you have:

 

TPick Bullet;
int hitPlayer;
TVec3 force;

if(LinePick(&Bullet, startPos, endPos)){

        //Use startPos & endPos to calculate the vector for the force. You will also have to normalize the force and give it a multiplyer to suit your needs This might 
       //help :http://www.leadwerks.com/wiki/index.php?title=AddBodyForceAtPoint

       force = /**a function of startPos & endPos I couldn't be bothered figuring it out right now**/;

        hitPlayer = atoi(GetEntityKey(Bullet.entity, "Player"));

        AddBodyForceAtPoint(player[hitPlayer]->playerBody, force, Vec3(Bullet.X, Bullet.Y, Bullet.Z));
}

And thats it XD

 

Disclaimer: This code is just for concept purposes you should be able to figure it out for your specific game based on the concept I have presented. Just don't copy it word for word :blink:

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

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