Could someone please give me some insight on how you would apply an arc to the trajectory of a projectile when using the gunScript and projectileScript (from the Rocket Launcher package)
I’m trying to put together some grenade mechanics, I’ve got pretty much every part of it built, the only two missing things are a more fluid animation, which I’ve managed to get started using the knife grip and writing the melee action into the gunScript logic, I’ve got it to the point where the animation is passable as “throwing”, the grenade mesh disappears from player’s hand at the peak of the animation like it should, but still working on timing the projectile to spawn at the peak of the melee animation, currently the projectile fires from the muzzle location on the button press (so a "projectile grenade’ flies out of the “held grenade” in the player’s hand at the beginning of the animation, when I need it to fire appx 0.45 seconds after the button press (which would be during the animation, not sure if possible), I’ve tried putting wait timers in many different places in the scripts to no avail. If someone could lend me ideas on how to postpone that projectile release by 0.45 seconds after button press, and give me insight on how to build an arc into the flight path of the projectile, I would appreciate it.
My guess is the best way to do that is manipulate the mass of the mesh template.
Crayta automatically calculates a mass for meshes based on size but you can override that to make it heavier and therefore fall faster. You could also lower the projectileExitVelocity property on the gunScript.
Thank you for the reply,
I actually forgot to mention–
The arch I am trying to create begins “upward” from the raystart. It wasn’t difficult to figure out how to get the projectile to go slow enough and have physics enables so it would fall/bounce/rest. What I am trying to do is make the projectile have a “toss” path, where the z-position increases a bit before the object falls. Like a rainbow
All you should need to do is set the initial direction vector pointing up. After getting the player direction vector, add another vector to it with the upward angle
and then normalize the new vector, before passing it to the move function on the grenade.
I got it working! Thank you! I also managed to fix my timing issue this morning.
Two more things I need to do.
Currently, the only player animation that looks remotely close to a “throw” is the Knife/Melee animation. The problem is that the mesh in the player’s hand remains at a fixed location in spite of the animation, so the muzzle the projectile fires from can’t be directly on top of the held mesh for 2 reasons.
The projectile collides with the player’s hand during the animation, which causes it to experience major velocity and rotation issues.
The projectile looks like it is firing from behind where it is released.
So I’ve tried to adjust the muzzle locator on the held mesh a bunch of different ways, but can’t seem to find the right location to make it look like and act like the moment the held mesh disappears the projectile mesh “takes its place”.