Game Development Community

Projectile Physics

by Dylan Sale · in Torque Game Engine · 12/13/2002 (8:28 am) · 4 replies

Hey, while working on Istope X, Eric asked me to make a projectile that would circle around the target. I did not know how to do this in scripting (although its probably easier than the way I am doing it :)) so I basically exposed the processTick function to the scripts (like the onCollision code is exposed). If a boolean is set to false then it uses the scripting physics and not the engine physics...

const char* newPos = Con::executef(mDataBlock, 5, "processTick",scriptThis(),posArg, vel, 
Con::getFloatArg(F32(TickMs)));

   dSscanf(newPos,"%f %f %f", x,y,z);
   newPosition.set(x,y,z);
Now it works up to the dSscanf(...) (I also tried calling getWord() using the Con::executef(...) command) but when it runs that function, it comes up with an error in msvcrt.dll and quits Torque.

What am I doing wrong? I have stepped though it and all the strings are in the right format ("float float float")

ARG please help me...

BTW I have taught myself all of this so its probably crappy :)

#1
12/13/2002 (9:51 pm)
*bump*, I know its a lot to read but please help... :)
#2
12/18/2002 (4:45 am)
i got it working yesterday, hehe I wasnt referencing the x,y,z variables, DOH ^_^

well anyways, so this is all working now and theres no performance loss that i can determine from using the scripts to move the projectiles... if anyone wants me to post my changes, ill submit it as a resource...

coolies ^_^ again

Dylan
#3
03/08/2003 (1:51 pm)
Dylan,
I wouldn't mind seeing what you did as either a resource or just a post.

Thanks
#4
03/08/2003 (4:39 pm)
ok.. gimme a bit to get one together..
There is a bit of a performance hit if you have a lot of projectiles, but other than that it's ok.

Maybe someone might be able to optimize it.