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"

Reflecting projectiles

Hey UE4 wizards!

Quick question that might be complicated to achieve but I'll give it a try. I am making a sidescrolling action game (metroidvania etc) where my player character can only melee attack, dealing damage using MultiSphere Tracing.

I now have an enemy turret.

However, since my player character cannot shoot, he needs to be able to destroy them. Creating the logic to destroy the turret using my melee attacks is easy and done but now I want my player character to be able to reflect the turret's projectiles towards it to destroy it, or kill other enemies that cross the bullet's path.

The turret shoots a static mesh projectile (actor blueprint) that has no collision (for now). The overlapping of the capsule collision on the bullet deals damage to the player, the destroys the actor.

I have looked a bit on the topic and I gathered that my projectile should be able to bounce to create the desired effect.

My logic to go about this would be something like this: I want the bullet to do a MultiSphere trace during it's movement that, upon hitting something (if it's the player character and if he's attacking) will reflect the projectile directly towards the origin (no fancy movement or whatever, just a 180 degree rotation and reflected with the same velocity).

How would I go about that?

The only code (blueprint) I have for now is the overlapping collision of the capsule that deals damage to the player. I have tried to implement my logic using a sequence on the On Component Begin Overlap (Capsule) but I'm pretty sure it's not the way I'd have to set it up.

Thanks in advance!


Product Version: UE 4.21
more ▼

asked Jun 27 '19 at 03:06 AM in Using UE4

avatar image

10 2 5

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

1 answer: sort voted first

Hey, all you should have to do is to Get the current Velocity and negate it and ofc apply that result again. something like this, hope it helps. alt text

negatevelocity.jpg (79.9 kB)
more ▼

answered Jun 27 '19 at 04:25 AM

avatar image

109 1 3 6

avatar image r0stro Jun 28 '19 at 03:44 PM

Thanks for the tip! I'll try this tonight and give a follow up

avatar image r0stro Jul 05 '19 at 02:57 AM

It worked! Thank you so much!

(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