Max Angular Velocity?
by Chase Webb · in Torque 2D Beginner · 04/14/2013 (5:48 am) · 1 replies
Just curious, but is there a way to set a maximum Angular Velocity on an object? I'm playing with some weird Point Force objects and some of them start spinning insanely when they get hit.
Torque Owner Joe Williams
Newborn Games
The other option is to enable the update callback when they're hit, and put something like this in it:
function object::onUpdate( %this ) { %objVelocity = %this.getAngularVelocity(); %objAbsVelocity = mAbs( %objVelocity ); %velocityLimit = 50; if( %objAbsVelocity > %velocityLimit ) { %this.setAngularVelocity( ( %objVelocity / %objAbsVelocity ) * %velocityLimit ); } }What that code does is set the angular velocity to the limit if it's current value exceeds that limit. It also accounts for direction.
There's probably a more elegant way of handling this that someone else can suggest, but that should get you headed towards the solution you need.