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"

[Newbie Question]Problem with setting up damage in a local multiplayer game

-Hello everyone.I posted already on the same matter earlier but i was too naive in my implementation and i thought that i had resolved the issue.So the set up is that i ' m prototyping a local versus game where players can also throw objects(spheres) to harm each other in various ways. -My problem is that every time i grab a sphere and try to throw it to other players everybody gets damaged and killed at the same time. -How can i set it up so that when a player picks up a sphere they*a)dont get damaged themselves , b) they can damage another player and c)*only that player that receives the hit gets damaged and not all the others.I have a common character blueprint for all the players called BP_Player and a base actor blueprint for the spheres (BP_Hamsterballs)which can damage the players( and also any children of the sphere class). -I know that this might be really trivial but i am really lost on how i could set up something like this.Any help is welcome!Thank you for your time!You can find some of the (wrong implementations bellow, i understand that the get player controller 0 helps only player 1 in this case). alt text

Product Version: UE 4.18
Tags:
bp-player.png (166.0 kB)
bp-hamster-ball.png (144.5 kB)
more ▼

asked Feb 28 '18 at 05:03 PM in Blueprint Scripting

avatar image

Ameletiadis
5 2 4 9

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

6 answers: sort voted first

my solution to this would be to set a variable on pickup. then compare to the variable when doing the hit event.

alt text

alt text

capture2.png (102.2 kB)
capture.png (185.9 kB)
more ▼

answered Feb 28 '18 at 10:52 PM

avatar image

ThompsonN13
10.1k 33 9 23

avatar image Ameletiadis Mar 01 '18 at 10:44 PM

I 've tried to implement your method but i had some problems again.I will try it again when i have a bit more time these days but thanks!I would like though to ask, since i am having 4 players in a local game what would be the best way to compare to each other?Through tags?I am asking that because i had situations where all the players would get damaged at the same time.Also is the best idea to have all the event hit , apply damage and any damage in the player class?

avatar image ThompsonN13 Mar 01 '18 at 10:59 PM

what do you mean compare to each other?

using the hit event should work ok though you may need to make tweaks to control how often it can occur. using a system that uses apply damage and event any damage or similar nodes in my opinion is the way to go since it will be much easier to troubleshoot. its also much easier to implement in the case of adding new character types or objects when the actors handle applying the damage to themselves.

avatar image Ameletiadis Mar 03 '18 at 07:41 PM

I am just kind confused because when i saw all player instances of bp_player (the player blueprint i use for all the players) die at the same time, then i noticed that it doesn't work exactly as i had in mind (for example let's say c++)that's why i brought this tag thing up.Anyway i just started trying again to solve the problem but it doesn't work, if i repeat your steps then the ball doesnt do damage to the player, but if a player runs into another they can kill each other.I really can't wrap my head around this, hopefully i will find maybe an alternative, My blueprint setup:alt text

playergrab.png (94.1 kB)
throwplayer.png (229.9 kB)
eventhit.png (142.9 kB)
eventdamage.png (187.7 kB)
avatar image Ameletiadis Mar 03 '18 at 09:44 PM

Alright i think a quick but not elegant fix to this is since i want the ball to have some force to it before dealing any damage to add a branch where i compare it with a minimum number , if it succeeds it proceeds to deal damage.I actually want the ball to have some force to them before damaging a player so i guess i would have to implement this at some point.Any thoughts on these events?alt text

eventhit.png (111.9 kB)
anydamage.png (120.3 kB)
avatar image ThompsonN13 Mar 03 '18 at 10:38 PM

id say your event hit should work pretty well as long as the math is right. i personally would have tried to make it a bit simpler by just basing the damage on velocity but thats just me.

as for your any damage event, i dont see the need for the cast and the branch. having the cast just limits what will be able to damage your character. as for the branch its completely redundant if you use the cast. you are a basically saying is the damage causer a hampsterball, yes ok then is the damage causer that is a hampsterball the damage causer. its like asking if something if like itself.

avatar image Ameletiadis Mar 07 '18 at 09:51 AM

Thanks for all the help!Yeah you are right i don't know what i was thinking at the moment!Unfortunately even if i got some core mechanics working, due to some clunkiness and inexperience from my part with unreal the rest of the people i am working on this prototype , decided doing it in Unity, so here we go again from scratch :p!

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

Have you tried without casting to character?

more ▼

answered Feb 28 '18 at 07:00 PM

avatar image

ZN-Games
21 1 3

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

you could ad a variable to the ball which stores the player who has spawned the ball. then your ball could ignore the spawning player...

more ▼

answered Feb 28 '18 at 07:45 PM

avatar image

ZN-Games
21 1 3

avatar image Ameletiadis Feb 28 '18 at 07:53 PM

The balls are already in the world!The players grab them and then they can throw them on the other players!If it was like you said , it would be simpler!

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

ah, i see .... another idea could be using tags, so each player has it's unique tag.

more ▼

answered Feb 28 '18 at 08:07 PM

avatar image

ZN-Games
21 1 3

avatar image Ameletiadis Feb 28 '18 at 08:39 PM

Alright i will try this way as well!In general i feel a bit lost but i guess its due to the fact i just started learning blueprints :p.Thanks!

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

As i understand your first post, your game is a multiplayer game? So, perhaps the problem with applying damage to multiple players has to do with replication? if for example, the health variable is replicated to the server and all the clients sync to that variable, this might cause the problem. Difficult to say, without knowing your project.

I would also recommend to build a simple test actor, which could receive the damage of the balls to get these problems solved. (Receive Any Damage, Set health, if health >0 destroy actor, and a lot of print nodes in between ;) )

I always set my damage type class in apply damage node to: "Damage Type" but I don't think this is necessary. Here you can also define a custom damage type, if needed.

more ▼

answered Mar 02 '18 at 11:43 AM

avatar image

ZN-Games
21 1 3

avatar image Ameletiadis Mar 03 '18 at 07:36 PM

Hello ZN-Games, the game is local multiplayer, same pc so to say and four controllers!I saw also a lot about replication but it from what i 've seen it applies to multiplayer games, see my answer to ThompsonN13 to see what my nodes look like!Of course i try using breakpoints but unfortunately they didnt help yet!Thanks again for your time!

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

Hello ZN-Games , i tried but no difference whatsoever, i think my main problem lies with seeing who the player that throws is and who the player that receives is through the player controller index number that each has ,but to be honest i am really lost on how i should implement that , thanks for your time!

more ▼

answered Feb 28 '18 at 07:23 PM

avatar image

Ameletiadis
5 2 4 9

(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