Game Development Community

Someone mind helping me with this little spring thingy?

by Jonathan Rose · in Torque Game Engine · 11/24/2005 (10:30 am) · 6 replies

So, I just got Torque 1.4 yesterday, compiled it earlier, and have been toying with it lately... trying to make a very rudimentary platformer engine right now. I have created a spring before, but can't quite get something right when working out of tutorial.base. Anyway, here is the method I've been using...

function Spring::onCollision( %this, %obj, %col )
{

echo( "Yay yay! SPring collide get!" );
%player.applyImpulse("0 0 0", "0 0 1000");

}

I've placed it both in my spring's datablock and in my players datablock, and the echo occurs, so I know the function is happening, so I imagine I must be doing something wrong with applyImpulse... because I get this in my console:

Yay yay! SPring collide get!

tutorial.base/server/spring.cs (0): Unable to find object: '' attempting to call function 'applyImpulse'

So... was the applyImpulse function renamed or something? I could have sworn something just like this worked the last time :/

#1
11/24/2005 (10:40 am)
Umm... you aren't declaring %player.
#2
11/24/2005 (10:46 am)
Yes you aren't declaring player. Maybe %obj is player replace %player with %obj.
%obj.applyImpulse("0 0 0", "0 0 1000");
#3
11/24/2005 (1:56 pm)
Yeah... uh... that was stupid of me.
Sadly though, I can't figure out how to get it to work... I've tried using %this.player in the form of %this.player.applyImpulse("X Y Z", "X Y Z"); , but still got the same error. I've tried using %obj [ %obj.applyImpulse("X Y Z", "X Y Z"); , and got no error, but nothing moved at all anyway... I've tried adding in %player to the function declaration (that was the first thing I tried) and got the same error. Can't quite figure it out #-#... I really need to figure out what I'm doing...
#4
11/24/2005 (3:46 pm)
You want to have whatever collides with the spring be affected.
%this = the datablock "Spring"
%obj = the actual spring object
%col = what hit the spring.
#5
11/24/2005 (8:32 pm)
%col worked like a charm. Thanks.
#6
11/26/2005 (1:28 pm)
Oh I thought the player was the spring silly me