Game Development Community

Problems with velocity

by Juha Saaristo · in Torque Game Builder · 04/23/2005 (4:29 am) · 11 replies

Is there a reason or known bug for velocities caused by setImpulseForcePolar and setConstantforcePolar? It seems i get different velocities even though same force is applied to exactly same kind of object.

thx in advance.

Juha

#1
04/23/2005 (7:43 am)
"setImpulseForcePolar()" applies the specified force instantly (impulse) once-only whereas "setConstantForcePolar()" applies the specified force continuously (constant).

Imagine "impulse" giving you a seconds worth of force instantly and "constant" giving you the same but over 1 second (integrated). Of course, "constant" will continue to apply the same force beyond 1 second until you ask it to stop.

Using the same force for both, you will get the same resultant force from "impulse" and "constant" after 1 second has elasped. Don't try testing this with the script "schedule" functions as they are not that accurate though.

Hope this helps,

- Melv.
#2
04/23/2005 (12:24 pm)
I'm using SetImpulseForce for firing projectiles at quite rapid bursts, only one impulse applied per projectile. They differ quite considerably in velocity even if i use same force. I'll try lowering the rate of fire if that helps.
#3
04/23/2005 (12:43 pm)
Melv, I've had the same problem where setting a constant polar force to an object and then setting a impulse force to simulate jumping.
At all times the jumping is inconsistant, sometimes jerky and has a wierd habbit of just shooting straight off the screen after a minute or two.Even though the size of the jump is never that high.
It really appears that the constant force is shut off for a split second or something.

I don'tknow if this is because I am simulating a bouncing motion by activating the impule in collision or not but it does seem wierd. I've read about this in a few different threads though.
#4
04/24/2005 (2:10 am)
I assumed you meant differing between those functions, not the same function call repeatedly, sorry.

I would set the linear velocity directly for projectiles unless you have a need to accellerate or adjust the forces. No need to make things harder than they need to be.

There were a few issues in v1.0.0. Have you tried this in v1.0.2?

- Melv.
#5
04/24/2005 (3:05 am)
Yes, the problem is with both versions. It's exactly the same behaviour in both versions. Would be nice to set it this way, but i'll just try setting the velocity directly.

Juha
#6
04/24/2005 (8:55 am)
Really wierd.

I've been playing with this and I'm not seeing it.

- Is there any trivial code you could post that shows the problem?
- What kind of frame-rate are you running at?
- Does it do this when you set a target FPS in the scenegraph (setScenePhysicsFPSActive)?
- What OS?

Sorry for all the questions, just trying to narrow it down.

- Melv.
#7
04/24/2005 (10:48 am)
Here's the code snippet used for creating bullet.

function FireBasic(%i,%angle)
{
 
        %ammo = new fxStaticSprite2D() { scenegraph = t2dSceneGraph;};    
        
        %ammo.typeID = $BasicAmmo;
        %ammo.setSize(2);
        %ammo.setCollisionPolyPrimitive(12);
        //%ammo.setDebugOn(BIT(5));
        %ammo.setLayer(4);
        %ammo.owner = %i;
        %ammo.setGroup(2);
           
        %ammo.setPosition($ship[%i].getPosition());
        %ammo.setRotation($ship[%i].GetRotation()+90);
        %ammo.setImageMap(particles1ImageMap, %i);
        %ammo.setCollisionActive(true , false);
        %ammo.setCollisionPhysics(false, false);
        
        if (%i == 0)
        %ammo.setCollisionMasks( BIT(7)| BIT(8)| BIT(9)| BIT(3),BIT(3));
        if (%i == 1)
        %ammo.setCollisionMasks(BIT(6)|  BIT(8)| BIT(9)| BIT(3),BIT(3));
        if (%i == 2)
        %ammo.setCollisionMasks(BIT(6)| BIT(7)| BIT(9)| BIT(3),BIT(3));
        if (%i == 3)
        %ammo.setCollisionMasks(BIT(6)| BIT(7)| BIT(8)|  BIT(3),BIT(3));
        
        %ammo.setCollisionMaterial(ammoMaterial);
     
        %ammo.setMaxLinearVelocity(100);
        
        
        %ammo.setCollisionCallback( true );
        %ammo.setLifetime(5);
        
        %ammo.setImpulseForcePolar(%angle, 250);
        //%ammo.setLinearVelocityPolar(%angle, $ship[%i].BulletSpeed);
        
        $ship[%i].AmmoCount++;
   
}

I'n running on windows XP, at frame rates of 120+ usually.
Scenegraph physics settings are at default, but i'll try tinkering with it.
#8
04/24/2005 (10:54 am)
Is seems t2dScenegraph.setScenePhysicsFPSActive(true); did solve the problem. I wasnt aware of this function before, but now it works perfectly. Thanks for your help.

Juha
#9
04/25/2005 (11:11 pm)
I'm not aware of .setScenePhysicsFPSActive. Is this new to the 1_0_2? Because (I can't even find it in the reference for 1_0_0?

if you set it to true what is it doing exactly?
#10
04/25/2005 (11:46 pm)
Charlie,

That's a new call in v1_0_2. You'll find it in the reference guide. It has other .setScenePhysicsXXX calls associated with it.

Essentially, it tells T2D to match a constant FPS, defined in another call.

- Melv.
#11
04/26/2005 (8:45 am)
Awesome, thanks melv. I'll have to try that out. It may help with my problems.