Can I have example project which using "LParabolaf"?

I have planned to create a form of character’s long-range attack.
Have anybody ever use “LParabolaf”? please tell me if it work.
It would be nice if I have some example of how to use it.

Thank you very much.

It is usually used with CollisionParabola.

Could you tell us what you are trying to accomplish specifically? We may be able to give more specific advice then.

1 Like

I’m trying to create a function which calculate a curve line projectile of arrow model.

– update –

I adapted these codes which found in the internet.
I felt that it has some problem that velocity of each launch angle is not equal
launching at 80deg is faster than 45deg.
I’m not sure if it was a problem of projectile formula.

Could I have your advice please?

from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
from panda3d.physics import *
from direct.task import *
import math

class loadModel():
    def __init__(self,obstart,mod1):

class GRun(ShowBase,dict):
    def __init__(self):
        taskMgr.doMethodLater(0.01,self.projectile, "ProjectTraject")






        # self.taskMgr.add(self.projectile, "projectile")

    def projectile(self, task):
        dt = globalClock.getDt()
        v0 = 5
        v1 = 50
        r = math.radians(77)
        g = 10
        h = 0
        x = self["BuiltInBall1"].getX() + v0
        z = self["BuiltInBall1"].getZ()
        if z >= 0:
            z = h + x * math.tan(r) - g * x**2 / (2 * v1**2 * math.cos(r)**2)
            self["BuiltInBall1"].setPos(x, 0, z)
            # if self.sound.status()==AudioSound.READY:
            # print(self["BuiltInBall1"].getPos())
            return task.again        

I may be mistaken, but my guess is that your speed issue comes from the fact that you appear to have fixed values for your vertical and horizontal speeds, regardless of starting angle of the projectile.

However, a projectile launched near-vertically will presumably have a greater vertical speed than horizontal speed, while conversely a projectile launched near-horizontally will presumably have a greater horizontal speed than vertical speed.

Or rather, the overall velocity should be the same regardless of angle–but the vertical and horizontal components will depend on the launch angle.

Specifically, I think that the relationship is simply a matter of sines and cosines: if the launch-angle is measured from zero being horizontal to pi being vertical, then–if I’m not much mistaken–the vertical velocity should be sin(launchAngle) * overallVelocity and the horizontal velocity should be cos(launchAngle) * overallVelocity.

That said, looking at the API page for the LParabolaf class, I see that it has a function that allows one to calculate a position on the parabola for a given point in time–which seems like what you want, essentially. It might be easier to simply use that!

1 Like

Thank you very much.

1 Like

Thank you very much.

I’m wondering how I would set the launch-angle into LParabolaf class.
It isn’t mentioned in the document.
would it be mentioned as “Start Point” ?

I haven’t worked much with the parabola class myself (if at all), I’m afraid, so I’m not confident in my answer here.

However, looking at Wikipedia’s article on such things, I think that it would be represented by the “initial velocity” vector.

(The “start point” would simply be the origin-position for the projectile, I daresay.)

1 Like