# ProjectileInterval - probably a dumb question

Decided to try this function for the 1st time. I have a model I thought I’d press a key and have them go up and down (basically, a jump). The code below makes them go up but they never come back down.
Obviously, I['m missing something very simple:

``````		startPos = self.model.getPos()
endZ = startPos
endZ.setZ(startPos.getZ() + RPG_FLY_HEIGHT)
myJump = ProjectileInterval(self.model, startPos=startPos, endPos = startPos, endZ=endZ, duration = 1, gravityMult=1)
myJump.start()
``````

causes this error:

``````   myJump = ProjectileInterval(self.model, startPos=startPos, endPos = startPos, endZ=endZ, duration = 1, gravityMult=1)
File "C:\Panda3D-1.7.0\direct\interval\ProjectileInterval.py", line 94, in __init__
self.__calcTrajectory(*args)
File "C:\Panda3D-1.7.0\direct\interval\ProjectileInterval.py", line 163, in __calcTrajectory
assert not endZ
AssertionError``````

You can’t specify both endPos and endZ. The z is part of the pos.

David

thanks.

I’ve changed it to:

``````		start = self.model.getPos()
end = start
end.setZ(end.getZ() + RPG_FLY_HEIGHT)
myJump = ProjectileInterval(self.model, startPos = start, startVel = Point3(0.0, 0.0, 0.1), endZ = end)
myJump.start()``````

but now i get

``TypeError: unsupported operand type(s) for -: 'float' and 'libpanda.Point3'``

what value should startVel have - the manual says Point3(X,Y,Z)

Now it’s mad because you’re passing a Point3 for endZ. That’s not right. If you specify endZ, it should be a single float. If you want to pass a Point3 as the target, that’s what endPos is for.

But note that you’re not computing the target pos correctly anyway. When you say this:

``end = start``

you are not assigning end to a copy of start. You are actually assigning end to the same object as start. This means that when you reassign end in the next line, you are also changing start at the same time! Instead of that assignment, you should do:

``end = Point3(start)``

which does make a copy. Or, since all you’re changing is the Z component, just forget about that, and pass endZ = start.getZ() + RPG_FLY_HEIGHT.

That’s probably what you have in mind anyway. Note that you also can’t specify both endPos and startVel. The set of things that you’re allowed to pass is all described in the API Reference for the ProjectileInterval constructor.

David

thanks again!

I’ve now got it down to 3 lines as you suggested.

``````		start = self.model.getPos()
myJump = ProjectileInterval(self.model, startPos=start, startVel = (1,1,1), endZ = start.getZ() + RPG_FLY_HEIGHT)
myJump.start()``````

and get:

``StandardError: projectile never reaches plane Z=100.0``

So something’s run with my startVel?
I’ve tried (1,1,1), (0,0,1), and (0,0,-1).

The manual doesn’t give much guidance on it other than to say that’s it’s a Point3. (it also says that for endZ). Sorry for all the questions, I’m a bit slower than usual on this one.

The standard units for ProjectileInterval is feet and seconds. The acceleration due to gravity is 32 feet per second squared.

If you launch your projectile with a velocity of (1, 1, 1) or (0, 0, 1), then you are specifying an upward velocity of 1 foot per second. If you specify a velocity of (0, 0, -1), then you are specifying a downward velocity of 1 foot per second.

I don’t know where it’s starting from, but if it’s starting from z = 0 (for instance), you’re going to have to throw it a lot faster than 1 foot per second if you expect it to get all the way up to z = 100.

How fast do you need to throw a ball to reach the roof? Pretty fast. If you just toss it up lightly, it’s going to go a couple of feet up and then fall back down, and never come close to the roof.

That’s what the error message is telling you. You didn’t throw it upwards fast enough to ever reach z = 100.

David

Thanks, makes perfect sense.
Had no idea what units startVel was dealing with.