#Projectile Fire Direction

1 messages · Page 1 of 1 (latest)

elder eagle
#

Hey
Im trying to make a simple and accurate projectile system.
I used gaze origin and also tried raycast but the bullet doesnt always go where I want.
I’m still learning and would really appreciate some help

ripe heron
#

oh wait, im abit dumb

elder eagle
ripe heron
#

custom projectiles?

elder eagle
#

they are not firing straight

ripe heron
#

if so:

  1. put a vector3 component infront of the gun (buller will spawn there)
  2. make sure the vector3 component is placed accurately and looks where the gun looks and not a degree in other direction
  3. you spawn the bullet on the vector position and rotation + add velocity that looks where the vector3 component looks
#

vector3 component should be placed on a distance where the object physically cannot touch the gun when at that position

#

easiest way to get it to go the right rotation is just using grid with 15-30 degrees set in grid settings

ripe heron
#

there's no big difference but set velocity is more reliable sometimes

elder eagle
#

but why would you need a Vector component?
This is more logical to me but its not precise enough

ripe heron
#

mostly so its easier to see and set up

#

but gaze direction gets the vector at which player looks, not the gun

#

so vr players will shoot it to their forward even if gun looks to their right

#

same for screenies that are in 3rd person

#

get forward vector of trigger handle to make it shoot where the gun looks

elder eagle
#

I only need the screen First perfective Version

ripe heron
ripe heron
#

technically possible but you have to look at projectile launcher part as abit separate object
make it rotate on its own and rotate it separatly from the gun

#

basically spawn the projectile in a position and set its velocity to vector [target pos - bullet pos]

elder eagle
ripe heron
#

oh wait

#

this is rooms 2.0 projectile system right?

elder eagle
#

I want to build the raycast version

ripe heron
#

speed is how fast projectile moves
direction is were it goes (set it to [target pos - bullet/origin pos])
other stuff is self explanatory

#

for raycast you first do a raycast, get a point where it hit an object, make a vector from bullet origin to that hit point (hit pos - origin pos), and set direction of the bullet to that

#

pos = position
origin = where you spawn a bullet
hit pos = one of output of raycast chip

#

i gtg so i wont be able to help for now