Post by moomanfl on Apr 1, 2008 21:10:14 GMT 1
I am currently working on a demo to try and get a "local gravity" system working (ie. each object has it's own gravity vector), but I have run into some problems so I am thinking that I might not have the right approach.
What I tried doing was using NDB_BodySetForceGlobal for two objects in my demo (two spheres). For one sphere the force was set with a -Y vector and the other with a +Y vector. No standard gravity is applied to either object. I found that I had to call this every loop to get it to work.
This works fine as long as the objects have no other forces applied (ie. Omega for a bit of initial spin). When I tried to apply a little initial spin, to make them roll a short ways on contact with their respective "floor" surfaces I got an unusual result: They would hit, roll a tiny bit, and then start accelerating until they zoomed off the surface.
I assume this has to do with the constant "down" force, however when using standard gravity and a bit of applied Omega it doesn't do this. The spheres roll a bit and then come to rest.
I would be grateful for any suggestions on how to get this effect working. Ideally I would like to have an object structure that keeps track of objects and their gravity vector so that objects can have their "down" direction changed dynamically but otherwise behave properly.
The code for my project and a zip containing the project itself and a compiled demo are on my first post here:
forum.thegamecreators.com/?m=forum_view&t=127072&b=1
As it mentions on that thread, there are two plugins needed (links provided) in order to compile the code, but the compiled program will work if you don't have them.
Any help and/or suggestions are much appreciated
EDIT: Have solved the problem. It was due to an misunderstanding of how the vectors in NDB_BodyAddForceGlobal should be applied. I set them to 0 for X and Z and the gravity force on the Y axis.... problem solved.
What I tried doing was using NDB_BodySetForceGlobal for two objects in my demo (two spheres). For one sphere the force was set with a -Y vector and the other with a +Y vector. No standard gravity is applied to either object. I found that I had to call this every loop to get it to work.
This works fine as long as the objects have no other forces applied (ie. Omega for a bit of initial spin). When I tried to apply a little initial spin, to make them roll a short ways on contact with their respective "floor" surfaces I got an unusual result: They would hit, roll a tiny bit, and then start accelerating until they zoomed off the surface.
I assume this has to do with the constant "down" force, however when using standard gravity and a bit of applied Omega it doesn't do this. The spheres roll a bit and then come to rest.
I would be grateful for any suggestions on how to get this effect working. Ideally I would like to have an object structure that keeps track of objects and their gravity vector so that objects can have their "down" direction changed dynamically but otherwise behave properly.
The code for my project and a zip containing the project itself and a compiled demo are on my first post here:
forum.thegamecreators.com/?m=forum_view&t=127072&b=1
As it mentions on that thread, there are two plugins needed (links provided) in order to compile the code, but the compiled program will work if you don't have them.
Any help and/or suggestions are much appreciated
EDIT: Have solved the problem. It was due to an misunderstanding of how the vectors in NDB_BodyAddForceGlobal should be applied. I set them to 0 for X and Z and the gravity force on the Y axis.... problem solved.