![]() |
Scripty mathy stuff
My head hurts.
Someone help me with this, or even work it out for me. ;-; verticalspeed = sin(zangle)*s verticalspeed -= .1 every .05 seconds horizontalspeed = cos(zangle)*s x = x + cos(angle)*horizontalspeed y = y - sin(angle)*horizontalspeed z = z + verticalspeed zangle = -pi/10 initial z = 8 initial x = 0 initial y = 0 I need it so when z = 0, x,y = finalx,finaly z = 0, x = finalx, y = finaly ;-; Help. |
Aroo? Could you tell me what you are trying to do? Make a custom projectile NPC? Doesn't Graal have a built in system for dealing with a 3rd dimension? Why are you going crazy with this stuff?
|
It's the formulas(ae?) for the built-in projectile's movement.
I need a formula so that it lands on the position I want it to.. The main problem is that I don't want it to go up and then down. I just want it to go down. |
So you don't really care what angle it's shot at so long as it lands in the right place and only goes down? You might be better off with algebraic parabolic motion than the trigonometry approach.
|
I've puzzled over this for awhile and eventually gave up.
At the time I didn't -need- it (was making a flak cannon-like thing on Archaic. instead of picking 7 xy's and doing it from there, i just did random angles and speeds) though, you could do a getangle to find the xy angle. that's the easy one. with the z angle, there's a whole line of possibilities - different zangles and different speeds. you could find working zangle and speeds using trial-and-error and testing to see if the distance works out (and possibly limit your search to a certain range of angles or speeds to make the result look decent) with a formula somewhat like this pseudo-code one: projectile_distance=projectile_speed*ticks_before_ impact you could find ticks with the cosine of the zangle times projectile speed and divide that by your gravity (since its a static reduction) somewhat like that would work (though i bet i confused you even more with that) now go get some advil for your [new] headache. |
It's called Mechanics 101. Take it.
|
Quote:
|
Quote:
Quote:
PHP Code:
v = sin(zangle)*power + 2t Now... PHP Code:
PHP Code:
Now that you got t... You can solve your location you want by... PHP Code:
PHP Code:
This is inaccurate in the sense that the speed is decreased only every 0.05 seconds, and so, the accelleration is actually an step-function. This means that for the period of 0-0.05, it decreases in an instance, rather than gradually, like in real life. It also means that it has the possibility to be off, but... Not by much. ^^; That's off the top of my head. I didn't check if I made mistakes. |
A small error in the above while rereading...
fx and fy weren't taken in consideration that partial power due to the zangle. :) |
Alright... I just made something for this... Anyhow... I was working on Projectiles for Relic, and I have encountered problems with the shoot as well...
After several hours of working on it... I found out the that gravity laws don't work. The reason for this is that the verticle speed, or the horizontal speed... Aren't in tiles per second, but rather in tiles per 0.05 seconds. This implies that if you had a power of 1, and you're going maximum distance, you go 20 tiles, rather than 1 tile.. distance = (v^2 * sin(2 * zangle ) ) / gravity So when Power == 1, and gravity == 1... Distance would give 1... But, if you make adjustments to the values, and treat them as per 0.05 seconds... Everything falls into place: Final Code: PHP Code:
|
| All times are GMT +2. The time now is 06:15 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.