Chiblue Posted February 14, 2010 Share Posted February 14, 2010 I have a Mesh that I am trying to push sideways... I have the object... and I create a cylinder, then parent it, assign a mass and then AddBodyForce, I want to move the object to the right when applying the force but I have tried just adding the force on the X axis, which works but when I rotate the object around the Y axis the object flies of in different directions, when in one direction is is fine, but them it goes forward left, obviously the function does not work how I expected it, or I am doing something else wrong.. Oh the object is set using PointEntity with the camera... so it is always pointing away from it.. (after a 180 rotation) TBody objectBody = CreateBodyCylinder(0.1, 0.3); EntityParent(object, objectBody ); SetBodyMass(objectBody ,0.1); EntityType(objectBody ,2); AddBodyForce(objectBody ,Vec3(10,0,0),0); Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
Niosop Posted February 14, 2010 Share Posted February 14, 2010 According to the wiki what you have should work, but it seems that it's applying the force using the global coordinate system instead of the local. You could try switching the third parameter to 1 or using TFormVector to create the vector you want in global space and use that. Oh, one other thing that might be an issue, if you are pointing the object and not the body then the body and model might be out of sync. So the body is still moving to its right, but the model is now facing a different direction. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Chiblue Posted February 14, 2010 Author Share Posted February 14, 2010 I basicall did that using the cos and sin of the Y rotation, but this did not help... Unless TFormVector does something more? if so what is the syntax? Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
Niosop Posted February 14, 2010 Share Posted February 14, 2010 http://www.leadwerks.com/wiki/index.php?title=Entities#TFormVector Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Niosop Posted February 14, 2010 Share Posted February 14, 2010 If using physics you should exclusively use physics. Use physics to turn the cube instead of PointEntity. You can't really mix manual positioning and physics, they don't play well together. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Chiblue Posted February 14, 2010 Author Share Posted February 14, 2010 If using physics you should exclusively use physics. Use physics to turn the cube instead of PointEntity. You can't really mix manual positioning and physics, they don't play well together. Please explain how I rotate a body in physics without using RotateEntity? I do not see any rotation commands in the bodies wiki? Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
Niosop Posted February 14, 2010 Share Posted February 14, 2010 http://www.leadwerks.com/wiki/index.php?title=Bodies#AddBodyTorque You can use CalcBodyOmega to help determine how much force you'd have to add, or just experiment a little bit. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Chiblue Posted February 14, 2010 Author Share Posted February 14, 2010 So what is the different between AddBodyTorque and AddBodyForce? Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
Niosop Posted February 14, 2010 Share Posted February 14, 2010 Force adds a pushing force, Torque adds a turning force. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Chiblue Posted February 14, 2010 Author Share Posted February 14, 2010 But I don't I want a pushing force to move the object sideways? Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
Niosop Posted February 14, 2010 Share Posted February 14, 2010 You want both. You want the pushing force (Force) to move the object sideways, and the turning force (Torque) to rotate the body. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Chiblue Posted February 14, 2010 Author Share Posted February 14, 2010 Do I have to position and rotate the body to match the mesh before attaching it to the mesh? TBody objectBody = CreateBodyCylinder(0.1, 0.3); PostionEntity(objectBody,EntityPosition(object),1); RotateEntity(objectBody,EntityRotation(object),1); EntityParent(object, objectBody ); SetBodyMass(objectBody ,0.1); EntityType(objectBody ,2); AddBodyForce(objectBody ,Vec3(10,0,0),0); Could this be the problem? Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
Niosop Posted February 14, 2010 Share Posted February 14, 2010 Try creating it in lua in the editor and turning on physics visualization so you can see what's going on. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Chiblue Posted February 14, 2010 Author Share Posted February 14, 2010 Thanks... I will do that... Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
Mumbles Posted February 14, 2010 Share Posted February 14, 2010 AddBodyForce(objectBody ,Vec3(10,0,0),0); Remember, that's only going to make the body to its right, irrespective of the camera's angle Changing the last '0' for a '1' will make it constantly make it move to the right in the world, irrespective of both the camera's angle, and the body's own orientation. If you instead write: TVec3 AddForce = Vec3(10,0,0); AddForce = TFormVector(AddForce,camera,0); AddBodyForce(objectBody ,AddForce,0); That will add the force relative to the camera angle (if your camera is called 'camera'). The above three lines could be condensed into one, as follows: AddBodyForce(objectBody ,TFormVector(Vec3(10,0,0),camera,0),0); ...And if the camera is constantly rotated to match the body's rotation, that gives a first person style view. Without meaning to be nasty, if you've not watched the 'introduction to bodies' video tutorial, it's worth watching. http://www.leadwerks.com/files/Tutorials/CPP/Introduction_To_Bodies.wmv http://www.leadwerks.com/files/Tutorials/CPP/Making_A_Spectator.wmv Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
Chiblue Posted February 14, 2010 Author Share Posted February 14, 2010 Remember, that's only going to make the body to its right, irrespective of the camera's angle That is exactly what I wanted to happen... Also I have benn through the tutorials, all of them... but like most the tutorials are a guide, after that everything is a learning experience... Without meaning to be nasty, if you've not watched the 'introduction to bodies' video tutorial, it's worth watching. The only reason I post these questions is that I know most of my chaleenges have been resolved by you guys in one way of another so I am simply looking for guidance, I appologize if it's a frustration but I thought that was the point of the forums to learn and help others... Quote If it's not Tactical realism then you are just playing.. Link to comment Share on other sites More sharing options...
Chiblue Posted February 14, 2010 Author Share Posted February 14, 2010 Try creating it in lua in the editor and turning on physics visualization so you can see what's going on. Did that and found my problem, the problem was that the body was not surrounding the object... I positioned and rotated the body before making it a child and now I have a perfect representation of the force I wanted... Thanks again... Quote If it's not Tactical realism then you are just playing.. 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.