I am new to UE4 and have started to try and create my own simple game. The idea is that the player controls four player blocks and they spawn when they player presses and holds a key, they then get destroyed when the player lets go.
Stage blocks move toward the player and the player gets points for as long as they hold down one of the four keys that relate to the player blocks.
I would like to have it where points are deducted from the total score every time a player block collides with a stage block. I am not having any luck getting this to work
I hope the images I have provided are sufficient enough for someone to understand the issue and help me.
(When I refer to the ‘Player’ I mean the literal player, as in whoever is playing the game)
Okay, so I have added a screenshot of what the game currently looks like. This should give you an idea of how the games works. The stage blocks move toward the camera. The player needs to hold down a specific key for each of the four player blocks to spawn in and they despawn when the player lets go of the key. The player gets points for every 0.1 seconds that a player block is present.
You’ll see in the screenshot that all four player blocks are populating the level as I’m holding down all four keys.
I updated the score system so it now uses a timer and it works great, thank you for the suggestion.
I also used bind for my widget and that also works great.
I still do not know how to get it so that points are deducted from the overall total score whenever one of the player blocks (depicted in the screenshot I added) collide with a stage block (also depicted in the screenshot I added).
So I think I’ve followed what you said. Problem is I don’t know how to get the point deduction value from the PlayerBoxLeft1 blueprint. I’m trying to cast to PlayerBoxLeft1 from the HUD widget to get the point deduction value but It just keeps saying I need to hook up an object. I can’t see any relevant object that I can hook it up to in order to get the variable I need.
I’ve added screenshots and text under each one, to make the problem clearer.
I was hoping that I could do this another way entirely as I would like to have the deduction value, let’s say ‘-50’ for example, pop up on screen every time the player loses points and then have it fade away until the next overlap event. Then I would like for the ‘-50’ to be taken away from the total points gained value. Rather than continuously have the deduction value increase and have that continuously be taken away from the total points value.
So I have moved all of the press key events and get points timers to a new character blueprint and hooked it up to the widget so It adds the points up correctly. On the individual blueprints for each player block I have set up the lose points function for adding up how many points need to be deducted and have set up the lose points timer for the overlap event. I will add the screenshot from the ‘PlayerBoxLeft1’ blueprint to show what each of these four blueprints look like.
So on the player character blueprint I have the ‘Total Points’ variable. How do I add the points to deduct value that comes from each of the four player box blueprints to the ‘Total Point’ variable on the player character blueprint?
I tried to use ‘Get Actor’ to grab the deduct points value from the ‘PlayerBoxLeft1’ blueprint and get that to add onto the ‘Total Points’ variable but it just encounters errors saying it brings back ‘None’.
I tried to edit the lose points function on the ‘PlayerBoxLeft1’ blueprint so that it casts to the player character blueprint and then sets the ‘Total Point’ variable but then the points on the HUD just flickers from the value after deductions and then back to the ‘Total Point’ value without the deductions every time the ‘PlayerBoxLeft1’ collides with a stage block.