Rick Posted July 20, 2013 Posted July 20, 2013 If I want to "shoot" something forward with physics and not have it drop at all or so little it's not noticeable, but not have it move all that fast, what functions/values should I be looking at? I never really messed around with physic projectiles before. Quote
AggrorJorn Posted July 20, 2013 Posted July 20, 2013 Perhaps the following: Simple box with box shape Apply force in direction Do not set a mass for the object. Quote
Mumbles Posted July 20, 2013 Posted July 20, 2013 Perhaps the following: Do not set a mass for the object. No, this makes a body totally immovable. You can't move it and no matter how small it is, if you place it on a train track -- worry about the train... It could be less than 1 mm wide, but if it's got no mass, nothing will move it... Turn off gravity and apply the "adjusted" (negligible) gravity yourself every frame. It's what you'd have to do if you were using raw, unwrapped Newton. Quote LE Version: 2.50 (Eventually)
Rick Posted July 20, 2013 Author Posted July 20, 2013 @Aggor I have a sphere csg object with a sphere rigid body where it has no mass to it. I place it right in front of the camera and call AddForce(0, 0, 100 * Time:GetSpeed()) one time to it and it just sits there in mid-air Quote
Rick Posted July 20, 2013 Author Posted July 20, 2013 OK, giving it a mass value, setting the gravity mode to false and giving it zero friction seems to work! Thanks all! 1 Quote
tjheldna Posted July 21, 2013 Posted July 21, 2013 Hi Rick This does it it's pretty much a cut and paste from my code so just let me know if you need any help as some bit's wont make sense. I also created a custom collision type too if you are wondering.... //Get the projectile direction Mat4 matrix = character->GetTargetEntity()->GetMatrix(); projectileVelocity = character->GetTargetEntity()->GetMatrix()[2].xyz() * 900; //Create the bulllet Shape* shape = Shape::Box(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.1F, 0.1F); GetTargetEntity()->SetShape(shape); shape->Release(); GetTargetEntity()->SetPhysicsMode(Entity::RigidBodyPhysics); GetTargetEntity()->SetMass(1); GetTargetEntity()->SetCollisionType(kCollisionProjectile); GetTargetEntity()->SetGravityMode(0); GetTargetEntity()->AddForce(projectileVelocity); GetTargetEntity()->AddHook(Entity::CollisionHook, (void*)ProjectileCollisionHook); GetTargetEntity()->AddHook(Entity::UpdatePhysicsHook, (void*)ProjectilePhysicsHook); Hope this helps! Quote
Rick Posted July 21, 2013 Author Posted July 21, 2013 Thanks tj. About the custom collision type, how do you define the reaction between the different types? In LE2 there was Collisions(1, 1, 1) for example. Quote
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.