Newbie torquescript questions
by Thomas Natale · in Torque Game Engine · 07/27/2005 (5:33 pm) · 10 replies
1) how can I get the vector of the muzzle from which a projectile is fired?
2) How can I alter the velocity of the projectile so that it can hit a certain vector?
Thanks.. I know it's really simply.. just need some help.. haven't been able to work on Torque very much
2) How can I alter the velocity of the projectile so that it can hit a certain vector?
Thanks.. I know it's really simply.. just need some help.. haven't been able to work on Torque very much
#2
The muzzlevector and velocity is this stuff: but how can I define a velocity that will REACH a certain point?
in this function:
Maybe I'll find the answer.. thanks again..
EDIT (questions): Would I really need to do all of the actual physics equations to actually calculate the velocity needed for the projectile to reach that point (%pos)? Imagine that %pos is taken from a mouse pointer.
And how would I return the position of the cursor (I'm making a god view game, RTS style sorta)?
Since I'm firing the projectile from a ship, with the view above, I was also wondering how I could make the projectile's trajectory more arc like , but the view doesn't allow the player to actually aim the muzzle up in the air, How would I do this?
07/27/2005 (11:35 pm)
Thanks,The muzzlevector and velocity is this stuff: but how can I define a velocity that will REACH a certain point?
%muzzleVector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%muzzleVelocity = VectorAdd(
VectorScale(%muzzleVector, %projectile.muzzleVelocity),
VectorScale(%objectVelocity, %projectile.velInheritFactor));in this function:
function CrossbowProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)%pos would be the position i would need to apply to the vector above in order to calculate the velocity... but it can't be called in onCollision because... well you know why.
Maybe I'll find the answer.. thanks again..
EDIT (questions): Would I really need to do all of the actual physics equations to actually calculate the velocity needed for the projectile to reach that point (%pos)? Imagine that %pos is taken from a mouse pointer.
And how would I return the position of the cursor (I'm making a god view game, RTS style sorta)?
Since I'm firing the projectile from a ship, with the view above, I was also wondering how I could make the projectile's trajectory more arc like , but the view doesn't allow the player to actually aim the muzzle up in the air, How would I do this?
#3
any help??
07/29/2005 (11:39 pm)
Ok i just got rtssk and i have the mouse pos now.... but i'm still struggling with the arc of the projectile, i forgot to mention that i want it to take a pre determined amount of time to hit the desired point (the mouse cursor coords)....any help??
#4
I mean, you'll have to calculate your arc basing on distance between you and the target point and the height you want the projectile to reach.
You can use the max-height of the shooten projectile (radius 1 of the ellipse) and the distance/2 (radius 2 of the ellipse) and do some scentific-calculator-operations to calculate half ellipse (an arc, indeed) and make the projectile follow that arc.
By the way, you're still leashed to the torque default firing routines, so I think you'll have to write yours.
I think the best solution would be to write a couple functions for calculating this arc, collision response actions, input managament (input that will call those functions).
Sorry I realize this is not easy/very useful.
Bye, Thc.
07/30/2005 (12:41 am)
I think it depends on the height you want the projectile to reach.I mean, you'll have to calculate your arc basing on distance between you and the target point and the height you want the projectile to reach.
You can use the max-height of the shooten projectile (radius 1 of the ellipse) and the distance/2 (radius 2 of the ellipse) and do some scentific-calculator-operations to calculate half ellipse (an arc, indeed) and make the projectile follow that arc.
By the way, you're still leashed to the torque default firing routines, so I think you'll have to write yours.
I think the best solution would be to write a couple functions for calculating this arc, collision response actions, input managament (input that will call those functions).
Sorry I realize this is not easy/very useful.
Bye, Thc.
#5
Any physics 101 class should introduce you to the formulae used to calculate (given a target position) the desired starting velocity and angle for a projectile. From there it should be easy to take the velocity and shove it into the projectile code.
You could also calculate an arc and so forth, but that's more of an animation solution than a physics solution. Depending on your game, one or the other would be more appropriate.
07/31/2005 (1:17 pm)
There are a lot of techniques to calculate ballistic paths for objects given a goal target/height. Time is controlled strictly by the length of the path and the speed of the projectile. Intriguingly, calculating such paths was a major impetus for military funding of early computer development - a single simple computer could calculate tables that could hugely increase the accuracy of firing a thousand times faster than hundreds of humans working the problems out on paper.Any physics 101 class should introduce you to the formulae used to calculate (given a target position) the desired starting velocity and angle for a projectile. From there it should be easy to take the velocity and shove it into the projectile code.
You could also calculate an arc and so forth, but that's more of an animation solution than a physics solution. Depending on your game, one or the other would be more appropriate.
#6
07/31/2005 (9:27 pm)
I see. thanks for your in depth answer.
#7
I saw the "term" 101 applyed to various things, and as I understood it's used to mark the thoroughness of something (like say A to Z).
But I wonder what's the origin of that 101? I think something grade-related (school grade) but I'm unsure even about this because here we have grades from 1 to 10 until University, and then 1 to 30 for examinations alone (in Uni) while 1 to 110 for the final Uni exam.
Thanks in advance for reply (if any).
Bye, Thc.
08/01/2005 (6:05 am)
Totally Off Topic:I saw the "term" 101 applyed to various things, and as I understood it's used to mark the thoroughness of something (like say A to Z).
But I wonder what's the origin of that 101? I think something grade-related (school grade) but I'm unsure even about this because here we have grades from 1 to 10 until University, and then 1 to 30 for examinations alone (in Uni) while 1 to 110 for the final Uni exam.
Thanks in advance for reply (if any).
Bye, Thc.
#8
08/01/2005 (6:31 am)
101 generally refers to a base level college class, often rudimentary or indtroductory in nature, i.e. Computer Programming 101: Intro to Logic and Algorithms.
#9
Edit: Kirby got a post up first.
08/01/2005 (6:37 am)
101 refers to college courses (at least here in the U.S.). Usually the first course, and the most basic is 101. There are 060, 095, 100 and course numbers below 101 which are introductory courses.Edit: Kirby got a post up first.
#10
08/09/2005 (10:58 pm)
Then 201 for sophomores, and so on until your hardest classes are 400 something. I even got into 500's as an undergrad, though those are usually reserved for grad students.
Associate Kyle Carter