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"

Keep track of number of MP kills? (blueprints)

I feel like I should be able to figure this out considering I'm at this point in my project... but I think some guidance would be helpful here.

Basically, I have an MP game where there are human players and NPC enemies. I want to know of a simple way to log when a player kills a human player or a NPC separately. Starting with the human player.

I'm using line traces for shots. This works good. People die its all fun stuff. But the line trace originates from one player, and then applies x damage based on where the shot lands. The hit characters bp controls the take damage. I cant see how the shooting character would know whether or not they zero'd out the hit players health since they are in separate BP.

While writing this I just thought maybe I can store characters health into a unique variable in GameInstance_c called something like Player1Health.

And when apply damage is done in player1 char bp it updates this variable. If it hits Zero then theres now a shared variable I can use to populate a score... but understanding how to make sure the shooting character gets the credit is where im a bit fuzzy.. thats if this is even the proper way to handle such things.

Thanks in advance for any ideas

Product Version: UE 4.7
Tags:
more ▼

asked Jun 06 '15 at 03:27 PM in Blueprint Scripting

avatar image

thankstipscom
654 39 38 72

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

4 answers: sort voted first

I feel dumb. I figured this out in like two seconds when I actually started writing it out....

(after shot hits) Get Hit Actor -> Cast to Mychar > Get Health > If = or less than 0 > Take "MPKills" and +1 and Set MPKills

blargh

EDIT: its actually not fully working. Once the "shooting" character is killed, the tally is reset on respawn.... it needs to persist. hmmm..

EDIT 2: After checking if the shot player died I cast to a custom playerstate that you can make (and use in your project settings) of the shooter and add increment one to a variable called kills. At the same time update a local variable on the character bp with the same value in playerstate so that the UMG updates (set it from playerstate to character). Basically just save everything in playerstate variables and call them when you need to. Playerstate persists. Theres something finnicky with casting to playerstate sometimes but it works with some trying.

alt text

more ▼

answered Jun 06 '15 at 04:03 PM

avatar image

thankstipscom
654 39 38 72

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

Enemy chected should have damage applied right calling function to hitted enemy? (i think UE4 got system for damage apply, check it out) On damage apply check if enemy heatl is

more ▼

answered Jun 06 '15 at 03:52 PM

avatar image

Shadowriver
37.3k 936 172 1116

avatar image thankstipscom Jun 06 '15 at 03:56 PM

Damage apply is already working. Players die when they're health reaches zero. I can keep track of how many times a player has died in the character blueprint. The issue is how do I keep track of how many players a character has killed. since they dont see the damage taken by the character they shot at.

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

I know this Question is very old, but a nice way I used to keep that communication up is by adding a (reference to Self) to the damage message, then whomever receives the damages gives a response back to the person who sent the message (that opens a two way communication between shooter and target, then it makes it easier to store information like that :). (I agree on saving in the player state.. although I use a gamestate makes it easier for me to keep track of all players ..

more ▼

answered Jun 24 '16 at 05:35 AM

avatar image

ScRuFFnuF
25 1 1 5

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

I know this Question is very old, but a nice way I used to keep that communication up is by adding a (reference to Self) to the damage message, then whomever receives the damages gives a response back to the person who sent the message (that opens a two way communication between shooter and target, then it makes it easier to store information like that :). (I agree on saving in the player state.. although I use a gamestate makes it easier for me to keep track of all players ..

more ▼

answered Jun 24 '16 at 05:36 AM

avatar image

ScRuFFnuF
25 1 1 5

(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