| Blockland Forums > Modification Help |
| Help with spawning projectile via function? |
| << < (2/2) |
| PhantOS:
keep in mind that if you're spawning a projectile from the player, you'll want to rotate the velocity vector relative to the player's eye vector (ask visolator for help on this) if you don't the projectile will always go in a certain direction regardless of which way you're player is facing. |
| xS K I D z:
--- Quote from: Kyuande on September 29, 2017, 01:52:20 AM ---Initial velocity is a 3 field vector (Vector3F) (X Y Z), your field is only an integer. Always remember that velocity is a direction of speed, stating the speed in an integer will not make sense. What direction to do you want the projectile to go to? --- End quote --- Thanks :) What I posted above was actually just an example from somewhere, just wanted to make sure people know what I'm after. But I did have just an integer so I will look up my references on Vector3F stuff. And what PhantOS said, I want the projectile to be spawned relative to where the player is facing, "forward". --- Quote from: PhantOS on September 29, 2017, 02:04:18 AM ---keep in mind that if you're spawning a projectile from the player, you'll want to rotate the velocity vector relative to the player's eye vector (ask visolator for help on this) if you don't the projectile will always go in a certain direction regardless of which way you're player is facing. --- End quote --- Yea it's pretty wonky atm lol. Thanks for the help. I'm gonna see if I can find some more examples on the eye vector cuz my reference sites are not helping much. |
| Kyuande:
Getting the eye vector is super easy because is already a function. Another vector is forward vector, easy for pushing people forward when you multiply it. I will create a few velocity examples when I get back on later if no one does |
| PhantOS:
vector math is a bitch by default |
| Kyuande:
Examples of velocity you can use (for a projectile) - the examples may or may not be correct or might be overcomplicated, but try the 2nd example and see if that's what you are finding: //This is an example of how to fling a projectile in a direction the target is (homing) using ImageName::onFire(%image, %player, %slot) - Will have to create own vars other than %player %vec = vectorScale(vectorNormalize(vectorSub(Vector3F %posA, Vector3F %posB)), int %scale); //example: vectorScale(vectorNormalize(vectorSub(%player.getPosition(), %targetPlayer.getPosition())), 80); //Example of shooting from the muzzle's velocity using ImageName::onFire(%image, %player, %slot) %vec = vectorScale(%player.getMuzzleVector(%slot), %image.projectile.muzzleVelocity); |
| Navigation |
| Message Index |
| Previous page |