Rotating object off-pivot

Hello,

is it possible to rotate a dynamic rigid body object off-axis (not around its pivot-point) if the rotation is applied via Torque or angularVelocity?

Can’t seem to find a working solution for this.

If I put the pivot point to the location I want the object to rotate around, the center off mass is off and the object starts falling over…

Thanks for any advices in advance!

You can use applyImpulse

orbiting = rotation + motion (local space of course)

It does not matter if you use physics (velocity or torque) or if you use teleportation (loc/rot).

Be aware this does not use an explicit center.

Force is applied at object center, and so is torque. An impulse has a world position, but has its own caveats.

Or you can do the transformation yourself using the vector math:
force.cross(radius) = torque

Where both force and radius are vectors. And because force, acceleration, velocity and displacement are all handled the same (mostly) you could replace that with:
linear_displacement.cross(radius) = angular_displacement

There are some other useful rearrangements of this, so if you need a hand, let us know more specifically what you want to move where.

step 1 create empty

step 2 place empty at pivot

step 3 get localized point of object to apply force vs empty location

step 4 rotate empty over time to create arc using local point

step 5 (concurrent w/4) applyForce on object directed to local point as it moves along the arc.


import bge

cont = bge.logic.getCurrentController()
own = cont.owner
target = own.scene.objects['someObject']
if 'pivot' not in target:
    pivot = own.scene.addObject('someEmpty',own,0)
    target['pivot'] = pivot
    pivot.worldPosition = (pivot point)
    diff = target.worldPosition - pivot.worldPosition
    local = pivot.worldOrientation.inverted()*diff
    target['local'] = local


else:
    pivot = target['pivot']
    pivot.applyRotation(some rot,0)
    local = pivot.worldTransform*target['local']
    distance, vectTo, localTo = target.getVectTo(local)
    force = distance*distance
    target.applyForce(vectTo*force,0)


Thanks for all the answers, until now I am not sure if I understood how I could apply that information to my game object.
Here’s a pic of the situation:


The highlighted cube on the ground is the dynamic object. The rotation axis should be around the middle of the player model (for spins and flips -> where the 3d cursor is located).

Unfortunately, I suck at coding, so I am not sure if the provided code is applicable to my dynamic object.
The good news is, that I apply the rotation via a python script (obj.setAngularVelocity([rotationAngleX, rotationAngleY, rotationAngleZ], 1), so the implementation probably will be easier.

So, is the code give above applicable for the situation I want to use it?

P.S. I tried to apply the code but I must admit, I don’t get it at…
I just don’t understand what the code does.

import bge

cont = bge.logic.getCurrentController()
own = cont.owner
target = own.scene.objects['someObject']                 #Would this be the Empty acting as the pivot?
if 'pivot' not in target:
    pivot = own.scene.addObject('someEmpty',own,0) #Why is here added another empty?
    target['pivot'] = pivot                                          #Is pivot assigned to a object's property? What kind of variable is it?
    pivot.worldPosition = (pivot point)                        # What is pivot point?
    diff = target.worldPosition - pivot.worldPosition
    local = pivot.worldOrientation.inverted()*diff
    target['local'] = local                                           #Is this again another objects property called local?




else:
    pivot = target['pivot']
    pivot.applyRotation(some rot,0)
    local = pivot.worldTransform*target['local']
    distance, vectTo, localTo = target.getVectTo(local)   #what happens down here?
    force = distance*distance
    target.applyForce(vectTo*force,0)

Here’s an example blend, I couldn’t adjust the code since I don’t understand it.

needHelp.blend (481 KB)

Attachments

needHelp.blend (480 KB)

if you rotate the pivot object it should move the agent in a arc around a point, try [0,0,.1]
(this does not include the facing code atm)

I still couldn’t figure it out what was meant. Could anybody help me out with this one? maybe with a simplified .blend file?

if i get a minute I will post a .blend (I am working / on a smartphone atm)

also what I proposing is to pull a object along a arc on the ground

are you talking about shifting a objects origin?

Yes, exactly, instead of pivoting around the objects origin I want the pivot point to be around the middle of the body of the player model. The bounding box origin has to stay where it is due to the center of mass.