Launching a wired projectile
by Lawrence Benedicto · in Torque Game Builder · 04/21/2007 (10:34 pm) · 4 replies
Alright, I'm trying to approach the issue of launching a wired projectile. I've got a few options for displaying the rope(or chain, or wire). I could make one very large png of the rope, somehow make part of it invisible (mask?) as it moves out from under the mask and the point of origin. Not really sure if there's a way to make a mask like this, anyone know?
If the particle engine will make it's emmissions uniform enough, I could even use it to create links in a chain. I doubt this idea is practical.
Or I could make sections which will fit under my point of origin, create them and extend them outwards as the projectile is moving. I'm concerned this will take up too much memory.
Does anyone have any tips or ideas on how to solve this problem?
If the particle engine will make it's emmissions uniform enough, I could even use it to create links in a chain. I doubt this idea is practical.
Or I could make sections which will fit under my point of origin, create them and extend them outwards as the projectile is moving. I'm concerned this will take up too much memory.
Does anyone have any tips or ideas on how to solve this problem?
About the author
#2
I did want the rope to be perfectly straight, and here's what I did:
I took the end and beginning coords to determine distance and angle. I created an 'array' (not really an array I know) of sprites with the cable segment image map. I created each new element in the array the 'length' of each cable out towards the destination (more on this in a moment) and made them invisible. I then used scheduling to incrementally turn visibility on for each element.
For anyone less math inclined, like me.. Here's the code for finding the position a certain distance away from the origin object in a particular direction (psuedo code).
Do this for each element in the array.
I haven't taken my trig yet, so this is new to me xD.
05/21/2007 (2:14 am)
An update on this, I achieved the effect eventually xD.I did want the rope to be perfectly straight, and here's what I did:
I took the end and beginning coords to determine distance and angle. I created an 'array' (not really an array I know) of sprites with the cable segment image map. I created each new element in the array the 'length' of each cable out towards the destination (more on this in a moment) and made them invisible. I then used scheduling to incrementally turn visibility on for each element.
For anyone less math inclined, like me.. Here's the code for finding the position a certain distance away from the origin object in a particular direction (psuedo code).
Do this for each element in the array.
%currentX = %currentX + %distance * mcos(mdegtorad(object.getRotation())); %currentY = %currentY + %distance * msin(mdegtorad(object.getRotation()));
I haven't taken my trig yet, so this is new to me xD.
#4
05/21/2007 (7:47 am)
Lawrence, thats funny you posted that - i am trying to do something similar (projecting a line at an angle, and needing to determine points along the line). i'm pretty sure my code for X and Y is the same, but i'll have to double check cause it wasn't working correctly. does it work with any direction (angle)?
Associate David Higgins
DPHCoders.com
the particle effect idea might work, but that depends on how long you want your rope to stay present ... if your doing something like the mortal combat "Come Here!" rope thing ... then a particle effect would be best most likely ... as it could trail behind the projectile ...
if you want it to persist, a particle effect would not be the best route ...and, depending on how many 'chains' you'd be creating ... the chaining thing would work too ...