There are two collision spheres. Normally, the player interacts with the Sphere collider, but upon getting the power up platform, the Sphere is deactivated and SphereBIG is activated. The only difference is the scale.
The power-up platformâs blueprint goes like this.
I am using the Cast All Actors node so that the âpotlickerââI know, itâs a fun nameâpower-up can talk to all the âcollectableâ objects in the level at the same time. The Collectable objects never get spawned in after the level starts. They are all placed by hand.
It looks like stepping on the Potlicker platform does cause the script to iterate through all of the Collectable objects, but it seems like the spheres are not being turned on and off as instructed.
THe way it should work is that when the player overlap (step on) the platform, it deactivates the collision box on the platform, then gets all the actors in the âCollectableâ class. After deactivating Sphere and activating Sphere BIG on all of the objects, it then turns off the collider on the platform , waits for a number of seconds as a sort of âcool downâ then, reactivates Sphere and deactivates Sphere BIG. ⌠but it doesnât seem to be doing that.
When I step on the platform, Sphere BIG does not seem to be active and Sphere doesnât seem to deactivate either.
Youâre accessing the last element from the loop after the loop completed its interaction. Taking into account that GetAll fetches actors, there is no way of knowing what this does.
If you want to affect all actors after the Delay again, you will need to start new loop.
But you do have a great point. Pulling the attributes from the loop after the loop ended means that they arenât being used⌠so Iâd actually have to run TWO ForEach loops. One to start, and then one to change the object back⌠That seems costly, but I honestly canât think of another way to keep in communication with the Collectable objects.
Even if I donât use Activate/Deactivate to turn things on and off, I still have to get things on the collectable.
Maybe it would be wiser in the long run to define something on the player that pulls the objects closer. instead of depending on each object to do it.
(NOTE: I realize that number at the top left is coving it, but that is the Box Collider. I may change it out later to a better fitting one.)
I changed it to a Trigger thinking that things would work differently, but nope. The âboxâ collider is what the player is overlapping with and I donât want the player to be able to interact with it during the âcooldownâ delay node. So I am trying to disable it. Maybe I should just go back to changing collisions states.
Like I say, those nodes donât work, and itâs not a good way to do it anywayâŚ
A much easier way is for the player to just tell the blueprint to move toward them and give them a distance.
You can do it with event dispatchers. The objects listen to the player. The player can make one call, and all the objects know the distance and if they need to move.
When the player steps on the plinth, you can make a new call with a greater distance.
To give it a cooldown period, you can just set a timer, and not make the call again until the timer has run out.
This is about dispatchers:
I have to dash now, but could help you with it later if you get stuckâŚ
So I might be able to get the location and do something similar in the player⌠or maybe I can send events to the Collectable⌠Iâll give it a shot and write back.
Iâve actually gotten a ton of help from viewing other topics on this forum, so Iâll try to keep details of what Iâm doing here for future use as well.
Basically, you send an event to all listening attractables in one go. You could send the player location and they figure out how far they are from the player. Or you could send a distance, and they figure out if they are < that distance from the player.
If so, they can start the timeline.
You can also setup exactly the same sort of thing for âstop attractingâ, piece of pie after the first part.
When the attraction rate is greater, you can pass the rate also, and use that to change the play rate of the timeline. EtcâŚ
Any probs, just reply to this and Iâll take a look.
BTW, to get the parameter working on the main dispatcher ( it wants a signature ), just create a function in the player and give it the same sort of parameter. You can then look that up in the signature listâŚ
Thanks! I just realized that the Collectables are already getting the player position and comparing it to theirâs for the timeline to work.
As a bit of amusement for myself, I just told the timeline to trigger on BeginPlay and all the Collectables from everywhere got pulled to the player, so I should be able to just compare and use a subtract vector⌠or maybe a Distance To within the Collectable blueprint?
Although the Player doesnât exist until the game starts.
Hm I see. The question is when should the Collectable be triggered? Originally, it was triggered on collision of the Sphere Collider, But it ifâs waiting to be overlapped, that means the player has to come near it anyway.
So I could only imagine the Collectable cubes calculating the location on all of the frames.
A similar scenario arrises if I use a Distance To node from within the player.
I can only imagine something is always checking the distance constantly. Am I missing something?
This is what the dispatcher is for. The dispatcher says âattract nowâ, and the collectables take a look at how far they are from the player. They only start moving if theyâre within a certain distance.
If the distance is good, they start the timeline.
Tell me if youâre not clear and Iâll put some code together.
Hm, I still donât think Iâm getting it. I understand what the logic is suppose to do. But how will the power-up platform know when the player steps on it? Stepping on it is what activates the powerup to pull things from further away.
I was thinking I could have the platform send a message to the player which would then send an event to all of the Collectables, but it seemed like I had to do too many work-arounds. I wish I could just send a message from one actor to another with Event Dispatch, but it looks Iâd still have to cast which gets challenging when it comes to communicating between actors. Is there no simple way to communicate between actors? Getting all the actors in a specific class is the only way Iâm aware of to use something from all actors of one type or controlling something thatâs not currently in the world.
I have found a different solution though thanks to your help.
This is from the Platform you step on to activate the powerup.
I feel like this is a really dirty way to do it, but the Collectables are just checking all of the time and if they are between a specific number I set as a variable a d the distance, they come towards the player and the other stuff from above happens.
I know I didnât do exactly what you were suggesting and this may not be best practices, but this project is more of a learning experience of how to use blueprints in general as this is my very first time ever using UE to this capacity and also itâs a game jam so I am starting to run short on time.
Thank you again for you help! That goes for everyone here. I have learned a lot about Blueprints just from doing this.
And what I want, is when I step on the pad, I get to attract stuff from further away, but only for 2 seconds, and I canât start it again until that 2 seconds has run out: