- Code: Select all
class CRollerController : public IMotionEvent
{
DECLARE_SIMPLE_DATADESC();
public:
IMotionEvent::simresult_e Simulate( IPhysicsMotionController *pController, IPhysicsObject *pObject, float deltaTime, Vector &linear, AngularImpulse &angular );
AngularImpulse m_vecAngular;
Vector m_vecLinear;
void Off( void ) { m_fIsStopped = true; }
void On( void ) { m_fIsStopped = false; }
bool IsOn( void ) { return !m_fIsStopped; }
private:
bool m_fIsStopped;
};
IMotionEvent::simresult_e CRollerBallController::Simulate(IPhysicsMotionController *pController, IPhysicsObject *pObject, float deltaTime, Vector &linear, AngularImpulse &angular)
{
if( m_fIsStopped )
{
return SIM_NOTHING;
}
linear = m_vecLinear;
angular = m_vecAngular;
return IMotionEvent::SIM_LOCAL_ACCELERATION;
}
That being said I'm having a hard time figuring out how to use this thing to push an object around. I'd like to wire it up to WASD, and I'm in a position where I can do something like:
- Code: Select all
if ( pMoveData->m_nButtons & IN_FORWARD )
{
m_RollerBallController.m_vecLinear = Vector( 0, 500, 0 );
}
And that'll make it roll in some sort of... circle looking thing. However I'm not really following what's going on here so if someone could explain it in some simpler english that'd be helpful.
Also i can change m_vecLinear (which is a Vector) and m_vecAngular (which is an AngularImpulse), both seem to have a realtime effect.