x

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"

Local Multiplayer Self Damage Problem

When either player is behind another they can deal damage I do this by getting input key down time while a bool is set from the collision behind the player and when the key down is greater than 0 it will subtract health from the player.

My problem is that when I am behind the player I can damage them fine and only their health goes down but when I go infront of the player and then press the same action it will take away my health even though I'm attacking and not the other player.

Both actors are spawned from the same character bp and I assume the problem derives from it using the player controller since its index is 0 and doesnt account for the other players.

How would I go about fixing this? How do I only subtract health from the player that Im behind and prevent myself from damage when they are behind me?

Every other variable is set in the widget so it uses get owning player pawn so each character has their own individual variables its only the damage that is being set from inside the player bp itself so yeah Im not sure to how to go about this.

Thanks!

Product Version: UE 4.21
Tags:
more ▼

asked Feb 21 '19 at 10:54 PM in Blueprint Scripting

avatar image

Jinkuu
38 1 2 5

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

you basically just need to have a way to reference the actor your overlapping so that you can damage them. below is a little example i threw together that should work in your situation, though im sure theres a better way to go about it. what i did is when the input is pressed i got all actors of the class that can be damaged then for each one i checked to see if i was overlapping their damage box. if true then i apply damage. the cast should be superfluous but my editor was being weird about it so i added it in.

alt text

capture.png (163.4 kB)
more ▼

answered Feb 21 '19 at 11:11 PM

avatar image

ThompsonN13
9.3k 32 8 23

avatar image Jinkuu Feb 22 '19 at 06:25 PM

I tried implementing this but It only damages the player I'm controlling, also the way I have the health set up is by dividing a "current hp" float by a set "hp" float so I just subtract from the current hp to get the value and plug that into the hud when I want to damage the player.

Im doing this from inside the character bp itself and I'm assuming thats why its damaging the character I'm controlling only?

EDIT

I just got the same variables from the cast and that worked on damaging the other character, but would that mean I would have to cast to all of my characters each time this is pressed since I have multiple characters rather than only this one?

(comments are locked)
10|2000 characters needed characters left
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