-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).
Have you tried without casting to character?
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!
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…
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!
ah, i see … another idea could be using tags, so each player has it’s unique tag.
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!
my solution to this would be to set a variable on pickup. then compare to the variable when doing the hit event.
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?
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.
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.
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!
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:
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.
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?
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!