Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can shoot my projectile in the opposite direction in a 2d game?

I have a projectile firing to the right but if I am looking to the left it still shoots to the right. The spawn location of the projectile is done by getting the actor's transform. Any ideas?

Product Version: Not Selected
more ▼

asked Sep 14 '14 at 09:35 PM in Blueprint Scripting

avatar image

116 34 28 42

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first


here is your answer on how to get the pawn shooting in both directions.


more ▼

answered Sep 15 '14 at 11:51 AM

avatar image

106 15 16 23

avatar image VigeoJames Sep 16 '14 at 09:35 PM

Thank you!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

What vektor do you use for calculating the direction of the projectile? You would need to turn your Projectile to the specific direction at spawn.

more ▼

answered Sep 14 '14 at 10:00 PM

avatar image

6.8k 333 185 470

avatar image VigeoJames Sep 14 '14 at 10:44 PM

I figure this out but I am not sure if it was the right way. I had it change the velocity of the projectile into the negatives. It works but I am not sure if that was the right way

avatar image eXi Sep 14 '14 at 11:58 PM

The thing is: I don't know what your 2D Game is. Are you just firing straight to the left and right or can your player aim with the mouse? Or does he aim with the arrow keys in 8 different directions?

To give you the answer to your question, i would need to know this.

I will just answer as if you would only shoot lift and right.

Let's say your Character moves along the X-Axis. You left is negativ X and right is positiv X. Now you would check if the forward vektor of your character is positiv or negativ. But only the X of that vector. If it's positiv, you would shoot in (1, 0, 0). Is it negativ you shoot in (-1, 0, 0). (X, Y, Z) seen as a direction vektor.

Is this what you have done or at least similar? Than it's ok i guess. I always say: If it works, why not using it? (:

avatar image Erasio Sep 15 '14 at 12:15 AM

In a small 2D attempt of mine I rotated my character and spawned the bullets in with a normal positive velocity while setting their transform equal to the player transform.

That way it would always be rotated the way my player is rotated.

avatar image eXi Sep 15 '14 at 12:47 AM

This is also ok. Till now we don't know how his game works.

avatar image VigeoJames Sep 15 '14 at 11:47 AM

I can only shoot left and right. I have done it with a switch that turns on when i face left. I set the velocity to the negative. And reset it when I turn right. Seems like a couple different ways to do it.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question