Pseudo projectiles improvement (includes scarwy math)

redoing the formula and method to improve this more
any contributions would be appreciated
current formula for both x and y (the one that needs to be improved)

(a-b)*c-a

a= player coords
b=past coords
c= scale

main goals of improvement:

  1. (devices): be able to calculate projectile coords based on the last recorded past coords (meaning you would still be able to fire even when standing still where as to this guide you cant)
  2. be able to independently scale the projectiles distance independent of past coordinates while still maintaining accuracy and direction (whereas this guide the shorter/farther the distance between the past coords and player coords the less/more distance the projectile goes leading to inconsistency)

for more context on how the current system works
the guide I made has a similar but more buggy version to the current one

9 Likes

Ok… I tried your guide but some of the block code is hidden so I can’t replicate what you did and help

Its this pic
also i’m gonna be out for a while

1 Like
  1. I am assuming you want it so that if you move to direction a and stop, the pseudo projectile will still be fired to the same direction instead of not moving at all, so then
    Make a property recording the player’s speed, and only update projectile direction when the player is at running speed
  2. Is a bit complicated, i’ll draw a model in a while
3 Likes

Wait… what’s the scale in the formula? (I know this sounds kinda off-topic, but I just need some stuff, everyone)

wait I think I found the problem: if you’re standing still, the a=b, so a-b=0, 0*c=0, 0-a=-a
maybe try multiplying it by -1? (I havn’t tested it yet so it may not work)
wait this only works if you’re standing still now :expressionless:

math…?

MATH YEAHHHHHHHHHHHHH

anyways, so we’re tryna do pseudo projectiles…

quick question does gimkit do trig function in radians or degrees?

1 Like

Assume all measurements are in radians

let
(x,y) to be a projectile’s initial position.

Let
d be the direction, in radians, that the projectile is traveling, and its traveling at s terrain/s

The velocity of the projectile would be
(s * cos(d),s * sin(d))
After n seconds, the position of projectile would be
(x + s * n * cos(d), y + s * n * sin(d))

2 Likes

please explain this math to me so I can help

1 Like

“(a-b)+a”= what sets the projectile direction in relation to b which is the past coords while keeping it in a rotation axis of the player (minus the scaling)

the 'c" in “(a-b)*c+a” is to scale it or in other words progressively move the projectile
usually works better in decimals from 1-2 otherwise it scales it a bit too much then needed

other then that idk how to explain it any better :P

I’m good at math but my brain is tired
I’m sorry idk what ur saying :sob:

3 Likes

o_o

I wasn’t really using radians/angles because that was being a real pain
or velocity (tried it when I first was messing around to make pseudo projectiles)
but Ima try to make sense of this later and translate it

might try to remember what I found so difficult bout that method later

1 Like

If you shot a projectile at an angle of θ to the horizontal with an initial velocity of v0, its path would look like this:


You can then form a right triangle using the sides with v0, and two other legs (let’s say the horizontal one has length x and the vertical one has length y).

Taking the sine and cosine of theta would return the following:
sin(θ) = y/v0, so y = v0sin(θ), and cos(θ) = x/v0, so x = v0cos(θ).[1]

Basically, we’ve now split our velocity vector (it’s a vector because it has a direction and a magnitude) into two components. This allows us to keep track of the horizontal and vertical velocities with respect to time (so basically, we see how time affects the horizontal and vertical velocities).

Our velocity “function”[2] is v(t) = (v0cos(θ), v0sin(θ) - gt). gt is there to account for the gravitational acceleration (g = 9.8 m/s2)

It gets more complicated for the position function, so it helps to focus on one component of the position at once. The x-component is the easiest to understand. Because distance = rate x time, our x-position at t is v0cos(θ)t.

For the vertical component, it gets annoying because we have to factor in gravity too. We can just plug numbers into this equation:
D = -0.5at2 + v0t, where D is our distance and a is our acceleration. Plugging in g and our vertical component, you get y = -0.5gt2 + v0sin(θ)t. That’s going to be our vertical component

So the position follows s(t) = (v0cos(θ)t, -0.5gt2 + v0sin(θ)t) + D, where D is just the coordinates of our initial position. Hope that helps.


  1. This also works out if you use the Pythagorean Theorem and the identity sin2(θ) + cos2(θ) = 1 ↩︎

  2. This is called a parametric equation but I don’t think it’s necessary to know that ↩︎

4 Likes

But this only works on a platformer