Announcement

Collapse
No announcement yet.

Side Scroller shoot projectile in front of character

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Side Scroller shoot projectile in front of character

    How can I spawn a projectile when I press a button so it shoots out of my character and just goes straight?

    #2
    First make projectile that when spawned moves forward. For this you can use physics or "projectile movement component".
    Then get forward vector of character, make rotator out of it and spawn projectile with that rotation.
    Good idea would be adding like 50* forward vector to spawn location so projectile is not spawned inside character "private area".

    If there are gaps in your knowledge, watch some tutorials.

    Comment


      #3
      First of all setup a new actor.

      Add a collision component to it

      Then add either a mesh, flipbook, sprite, ect. Whatever your projectile is going to look like.

      Next add a Projectile Movement

      Click on your projectile movement and under the details tab set Projectile Gravity Scale to 0, that way it will always go straight.

      Should look like this:

      Click image for larger version

Name:	4vmrOrL.png
Views:	1
Size:	461.6 KB
ID:	1095028



      Next go into your character BP and set this up: You can skip the DoOnce and the Delay if you want, I just put that there so the player can only shoot once every 1 second, that way they can't shoot as fast as they click.

      If you have anymore questions let me know.

      Click image for larger version

Name:	MVaqvji.png
Views:	1
Size:	257.0 KB
ID:	1095029

      Comment


        #4
        I hooked everything up but it is only shooting to the right no matter where I face. Also what should I have the Offset value set to, and is the 'Sprite' the mesh of the character?

        Comment


          #5
          Yes sprite is the character, I had the same problem you are having and then I made the BP just like you see above and had no problems since

          Comment

          Working...
          X