Boomerang / Hookshot
by Nicolas Stohler · in Torque Game Builder · 05/31/2006 (12:57 pm) · 6 replies
I want to implement a boomerang / hookshot function for my top down shoter/puzzle game.
1) The first big question is (I'm still relatively new to TGB): is this possible with the TGB physics functions (and stable?)? or do I have to do my own calculations? the boomerang should slow arc away from the player and slow down (while moving away from the player), then regain speed as it travels back to the player. the catch position does not have to be equal with the throw position (it's some sort of intelligent boomerang that knows where to fly ;-) ). also, I'm playing with the idea to give to player an option to not catch the boomerang when it first arcs back, so the boomerang should go on and do another arc and return then...
2) has anyone done something like this before and could show me some lines of code to get me going?
thanks
1) The first big question is (I'm still relatively new to TGB): is this possible with the TGB physics functions (and stable?)? or do I have to do my own calculations? the boomerang should slow arc away from the player and slow down (while moving away from the player), then regain speed as it travels back to the player. the catch position does not have to be equal with the throw position (it's some sort of intelligent boomerang that knows where to fly ;-) ). also, I'm playing with the idea to give to player an option to not catch the boomerang when it first arcs back, so the boomerang should go on and do another arc and return then...
2) has anyone done something like this before and could show me some lines of code to get me going?
thanks
#2
The good news is that this isn't really difficult at all with script, will just take some tweaking.
05/31/2006 (1:12 pm)
Short answer: you'll need to do the specific physics for this type of behaviour yourself, given your combination of top down shooter and "3rd dimension physics"--in other words, there isn't a third dimension to apply forces against to slow down and speed up using innate TGB physics.The good news is that this isn't really difficult at all with script, will just take some tweaking.
#3
- Matt VG
06/02/2006 (4:49 am)
You could fake it by weakly mounting it to an invisible sprite and moving the sprite to the positions you want.- Matt VG
#4
I used this in Ruby's Eggcellent Adventure to get the bats to flock around the player. It worked out quite well in the end.
06/02/2006 (5:00 am)
Why not set a gravity point at the target location so that the bommerang arcs towards it. As it nears the target location, move the gravity point back to the player and it will arc back again.I used this in Ruby's Eggcellent Adventure to get the bats to flock around the player. It worked out quite well in the end.
#6
I get the angle between the enemy and the player, and then use that to set the constant force. You might need to play with the numbers a bit, but I'm sure with some tweaking you could get the right effect.
06/02/2006 (10:21 am)
Right, here's the script I used:function UpdateBatDirection(%enemy)
{
if (isObject(%enemy))
{
%dirToMove = t2dAngleBetween(%enemy.getPosition(), $player.getPosition());
%enemy.setConstantForcePolar(%dirToMove, %enemy.moveSpeed, true);
schedule(1500,0,"updateBatDirection",%enemy);
}
}I get the angle between the enemy and the player, and then use that to set the constant force. You might need to play with the numbers a bit, but I'm sure with some tweaking you could get the right effect.
Torque Owner Alex Rice
Default Studio Name