I am developing a 2D platformer game in Unreal at the moment and I’m somewhat lost. What I have until now is 2 players that are able to move around the platforms and a camera that follows them (also pans in & out).
I would like to add an item to the game, let’s say a ball that when a player collides with he ‘picks it up’. Now, I won’t have no animation for that or anything complicated - the player might as well just have a red outline whilst ‘holding the item’. I want the score to progressively increase by, say 10 points each second while the player ‘holds’ the item. If the second player collides with the first player (that is currently in possession of the item), the second player ‘steals’ it and his score will increase by 10 pts a second instead - until the first player takes it back, and so on.
TL;DR -
2D Platformer with 2 players.
Player 1 picks an item (collides with) and he gains score constantly.
Player 2 collides with player 1, he ‘steals’ item and gains score points for himself, again, continuously - 2 SCORE BARS.
And so on.
I do know how to script, say, a player picking up coins and increasing his score with each coin collected, but not this.
Any sort of help would be greatly appreciated. Thanks!
I have managed to make both characters pick up the item, and when they do, they get 10 points. However, the player doesn’t get 10 points every second because I don’t have a ‘GotItem’ function (event?) to test if and which of the players is in possession of the item. How can I do that?
I have attached some screenshots.
Also, is there a way I can make Player_1 get the item from Player_2 when they collide? and so on and so forth. I’m thinking there must be a way to identify which of the players has the item at any point in time, and if he does, he gets 10 points each second. I’m not sure how I could do that do.
Thank you in advance!
Like I showed you on the initial answer i gave you, you need a an initial “got item” event or function, and a different “give score” event or function.
Because for the timer to run, there needs to be an event or function with that name on that actor.
Also, Timers can’t call events or functions with parameters, like you do in the screenshot. Because the parameter will always return empty, so they don’t do it.
Hey, I already did try to do what you did in the screenshot. Thing is I don’t have none of your custom events and I barely have any clue how you got 'em. I don’t have no ‘GotItem’, ‘GrantPoints’ or ‘LostItem’ customs.
Ok I think I got it, sorry for being hardheaded.
I followed your screenshot and then simply connected the ‘GotItem’ custom to my OnPickUp function. Now any Player that grabs the item gets 10 points / timehere. Thank you!
Though, how do I tell that the player had lost the item?
When the 2 players collide the item must switch owners. Obviously that won’t virtually happen, but when the 2 players collide the player that had the item stops scoring and the other player starts getting points. So on and so forth. So I guess I need 2 separate score systems, one for each player?