Is there any way to disable gravity for a physics object, while keeping gravity for everything else? Or, at the very least, is there any Python method I can use to get the current world gravity, so I can negate it? In most cases, I would just use a constant gravity value and negate it in the script, but I’m making a template for others to use, so it would be better to be able to find the current gravity at script execution time.
Always apply force 9.8Z
Tada.blend (408 KB)
Suspends physics for this object.
then you can not push it, my way you can
you really did not even look @ my .blend yet…
these with high mass = “falling platforms” aka mario yo,
…I will fight you
CubeJumpMarioThrowback.blend (442 KB)
Patience, patience. I was just at my piano lesson for a half hour.
Well, I looked at your file, and it doesn’t really help with my problem. Someone might decide to change the global gravity setting to something other than 9.8. Wait, does anyone ever use a setting other than 9.8? Well, I may just have to leave it up to the user to make sure the amount of force matches the amount of gravity. Unless someone knows of a getGravity method…
@p9ablo: The issue with that method is that it disables physics completely. That means no collision detection.
force = gravity * mass
check out the Mario one the force is 9.8*mass
so use some script to get grav then mass then set force as mass * grav?
Ah, and therein lies the problem. I don’t know how to get the gravity from a Python script.
import bge cont = bge.logic.getCurrentController() own = cont.owner scene = bge.logic.getCurrentScene() gravity = scene.gravity own.applyForce(-gravity * own.mass)
I think you need * own.mass? (is that the call?)
Yes, actually you do. I edited my post accordingly. Thanks for pointing that out.
No problem I love physics!!
Thank you, that should do the trick.