Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by Grant. 02/24/26 22:21
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (TipmyPip, clint000, Grant, chsmac85, Martin_HH), 5,858 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Setting angular velocity? #87113
08/22/06 22:27
08/22/06 22:27
Joined: Aug 2002
Posts: 681
Massachusetts, USA
Ichiro Offline OP
User
Ichiro  Offline OP
User

Joined: Aug 2002
Posts: 681
Massachusetts, USA
Is there a way to set angular velocity on an object without applying torque over time? I'm trying to do this:

1. Get the linear and angular velocities of my object.
2. Remove the object from the physics engine (clears its linear and angular velocities).
3. Muck around with it.
4. Return it to the physics engine.
5. Restore linear velocity (simple enough).
6. Restore angular velocity (no clue?)

I suppose I could take a linear velocity at the center and one at the surface, then use those to (later) apply a velocity at the surface, but that seems needlessly messy.

Thanks.


Dejobaan Games - Bringing you quality video games for over 75 years.
Re: Setting angular velocity? [Re: Ichiro] #87114
08/23/06 07:03
08/23/06 07:03
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline
Expert
A.Russell  Offline
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
Yes, it is quite easy. Before you remove the object, record its velocity (use phent_getangvelocity). Then fire it up again:


phcon_setmotor(constraint2, vector(spinner_vel,100,0),nullvector,nullvector); //if this spinner is replacing one that went out of bounds, it should start moving like the old one

The second parameter is the important one. spinner_vel is the target angular velocity, and the next number, "100," is an amount of torque high enough for the oject to reach that target velocity within one frame (you might need to set this number higher depending on your situation). You can't set it too high, but if it is too low it won't start rotating at the target velocity.

Re: Setting angular velocity? [Re: A.Russell] #87115
08/23/06 14:42
08/23/06 14:42
Joined: Aug 2002
Posts: 681
Massachusetts, USA
Ichiro Offline OP
User
Ichiro  Offline OP
User

Joined: Aug 2002
Posts: 681
Massachusetts, USA
Ah. So, I assume I need to do something like...

1. Record the first object's angular velocity.
2. Reset the first object's physics params.
3. Add a second object.
4. Add a constraint between the first and second.
5. Use phcon_setmotor() to start the first object spinning again.
6. Delete the second object.

Do I have that right?


Dejobaan Games - Bringing you quality video games for over 75 years.
Re: Setting angular velocity? [Re: Ichiro] #87116
08/24/06 02:19
08/24/06 02:19
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline
Expert
A.Russell  Offline
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
More like this:

1. Record the entity's angular velocity
2. Dissable the physics
3. Do whatever to the entity
4. Re-enable the physics
5. use phcon_setmotor to get it rotating at the same speed it was before you dissabled it

You don't need a second object.

Re: Setting angular velocity? [Re: A.Russell] #87117
08/24/06 02:36
08/24/06 02:36
Joined: Aug 2002
Posts: 681
Massachusetts, USA
Ichiro Offline OP
User
Ichiro  Offline OP
User

Joined: Aug 2002
Posts: 681
Massachusetts, USA
That's good to know. Thanks much!


Dejobaan Games - Bringing you quality video games for over 75 years.

Moderated by  HeelX, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1