Godot Version 4.6.3 stable
Question
For more context, read my repo here
I’m trying to predict the trajectory of an object that you can throw in the game so you can see how far it will go before you actually throw it. But, I’m having trouble actually putting this into play. Here’s an example of the function I use to try and predict its path:
func predictTrajectory(delta: float):
deleteDots()
var rightStickX: float = Input.get_joy_axis(joystickDevice, JOY_AXIS_RIGHT_X)
var rightStickY: float = Input.get_joy_axis(joystickDevice, JOY_AXIS_RIGHT_Y)
var input: Vector2 = Vector2(rightStickX, rightStickY)
var inputNormal: Vector2 = Vector2(rightStickX, rightStickY).normalized()
var numDots: int = 6
if abs(input.x) > deadzone or abs(input.y) > deadzone:
for x in numDots:
#createDot(rightStickX * spaceBetweenDots * (x + .5), input.y * spaceBetweenDots* (x + .5))
#createDot(x*10, x*x)
x= x * 10
var myVelY = worldGravity * delta
myVelY -= inputNormal * myMaxSpeed * x * delta
var myPos = position - myVelY
print("Me ", myPos)
createDot(myPos.x, myPos.y)
Currently, the line produced is linear. I need something that looks like a parabola that actually reflects what the throw will look like. Can you help me with implementation?