Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / Having trouble applying force to objects

Author
Message
DarkJohn20
15
Years of Service
User Offline
Joined: 11th Apr 2009
Location:
Posted: 8th Oct 2009 01:12
I recently took a look at the Dark Physics Demo: Explosions, and I wanted to make my own test code. I took the function for createExplosion from the demo and put it in my code, but for some reason, nothing moves when an explosion is created.



Can anyone find any mistakes or give me any suggestions?
I have already tried changing the force and size of the explosion.
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 8th Oct 2009 04:48
Probably need to add more force with the multiplier. A 2.5 cube will have a mass in the hundreds of thousands. How much force did you try to apply?

Try something like this and experiment with the multiplier:


After you get it to work, to get more realistic force application try:


This will apply the force to the closest x,y,z of the cube and make it spin away more naturally when hit. Otherwise they just shoot away with the same angle facing they where when they got air born.

Regards
DarkJohn20
15
Years of Service
User Offline
Joined: 11th Apr 2009
Location:
Posted: 8th Oct 2009 04:58 Edited at: 8th Oct 2009 05:02
Duke, no luck. The cubes didn't budge at all. I added a 100,000.0 multiplier and tried all 4 modes for Phy add rigid body force. I also added a little to the force# when calling the function.

One thing I noticed was that in another demo, I couldn't get the key press to trigger what was supposed to happen. It's like space and other things aren't being recognized.

For reference, I tried the Gravity demo in Dark Physics. Spacebar would not give the cubes gravity, so I changed it to UpKey() and that didn't work either.

Edit: I added a print command to see if space was working, and it appears to be....I'm stumped.
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 8th Oct 2009 10:44
Do you get any of the demos to work when compiling them yourself?
I mean maybe the DarkPhysics plugin is not registered properly.
Kendor
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location: Malta
Posted: 8th Oct 2009 10:54
Nothing DarkPhysics related.

The variable Cube in the function is 0 since it is a local variable. Either set it as a global variable:



or pass it to the function:




Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 8th Oct 2009 18:23
Quote: "The variable Cube in the function is 0"


Facepalm (and i actually eyed trough the code twice)

Regards
DarkJohn20
15
Years of Service
User Offline
Joined: 11th Apr 2009
Location:
Posted: 8th Oct 2009 21:40
Thank you very much! I will have to remember that for future uses.
DarkJohn20
15
Years of Service
User Offline
Joined: 11th Apr 2009
Location:
Posted: 8th Oct 2009 21:45
One more thing, when I delete an object, do I have to call any Physics commands to say that object is deleted? In my code, when an object is deleted with Delete Object, Phy Update (I think) says that the object is missing. Not quite sure.
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 9th Oct 2009 10:17
Never delete objects. It's kind of hard to resist this, but in a sustained application it will make you loose performance. Make a function to cache away the objects and exclude them.

But if you delete objects the way to go is to delete the rigid body's linked to the object number first.


Regards
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 9th Oct 2009 14:22 Edited at: 9th Oct 2009 14:23
I too have run into problems when trying to delete rigid bodies. The problem occurs most often with "Mesh" rigid bodies, especially with 3DWS objects. The problem is quite severe since I have to delete all of the rigid bodies between levels, and the only work around that I have found is to end the simulation (which automatically deletes all of the rigid bodies), then restart it.

Login to post a reply

Server time is: 2024-11-24 17:59:22
Your offset time is: 2024-11-24 17:59:22