How can I move all actors?

Hey!

I am trying to move several (2) actors from an array in order to create a platform that moves in the Y direction infinitely. However I can’t figure out how to do it. I have managed to do it with only the timeline making a loop but when I try to modify the speed of the path through an event, they are bugged and only 1 moves.

I am trying to recreate “FlappyBird” as a first game for learning purposes. And I want that when an input is executed, the platform starts to slowly increase over time. I have tried to use the “Event tick” and “Timers” but when I add a bit of speed, the two actors do not go in sync and this has led me to understand what a “Get all class actors” is. But now I don’t know how to tell all the actors what I want to do through the array. I’m pretty new so I’d really appreciate any help.

My current code:

Thanks so much for reading.

Cheers!

I would do this in the actor BP, if you don’t want them to stop ever like in flappy bird then you can probably just add a certain float to actor y off of event tick or set a repeating timer by event with your desired tickrate and just do your location calculations off of that, if you’re picky about event tick.

You could also use the character movement system in UE and fix the movement input to 1 on y axis that way you have a little more fine tune control of the actors speed right out of the box, and can use the built in jump system.

If you do it inside the actor blueprint you don’t have to worry about casting to all of a class because each instance will behave the same on begin play.

I’m no expert though, someone else can probably give you a better suggestion.

** completely disregard most of what I said, I thought you were trying to move the bird, and a second bird for some reason lol. My comments about the actor bp still would apply I imagine for the pipes

2 Likes

Hey! Thank you very much for reading my message.

I must admit that you made me laugh to see that you had been so detailed with me and then retracted almost everything you told me hahaha. In the same way it is my fault because I have not explained myself correctly.

I’m trying to move Flappy’s base infinitely with 2 actors which are two bases that I want to reposition to the start after giving it the start command which would be an input. But I don’t know how to make the 2 actors follow the same movement since I don’t know how to call them so that they do exactly the same as the other. I also want that when the input event (start of the game) is executed, it starts to gradually increase the speed of the platform. Either with a timer or with the “Event Tick.”

FlappyBase:

Thank you very much again for your help!
Cheers.

After all night and half an hour trying, this is the only thing I have achieved.


It seems that the two bases move at the same time since the one on the left is missing. But I need to know how to position them in the correct location separately so they don’t get together like that. Then, I want to be able to progressively increase their speed with the execution of an input to create an effect of difficulty over time.

I would GREATLY appreciate any help as I’ve spent endless hours trying to solve the same thing.

Thanks so much for reading.
Cheers!

Argh!

Be mindful of your execution flow (the white line). You should never use the outputs of a node that hasn’t executed yet.
Here are some examples of things to AVOID :

Anyways back to the point, I don’t think you want to use a timeline for this. Timelines have a start and an end. In your case, it is supposed to go on forever. Use event Tick instead.

Use AddActorWorldOffset to move the actor/root component without calculating the location. You only have to specify the offset to move every frame.

Use Tick delta time to make movement speed independent of framerate. If you move by +10 per frame, you’ll move twice as fast at 120fps compared to 60fps. Multiplying by delta time solves this.

1 Like

Hey! Thank you very much for taking the time to help me with this. Your answer definitely helped me understand the execution flows much better. I also understood the way to create an infinite movement thanks to you.

Finally after creating the movement, create a “TriggerBox” that when touched moves the actor to the initial position checking which actor has been the one who touched the “TriggerBox”. I don’t know if it’s done right but it works. Obviously I want to do things right, so if you see something out of place and want to tell me, I’d appreciate it. I try to get the base to be repositioned and the obstacles I’m about to create are destroyed and a new one is created or they move from position to the beginning with another height. I’m still not very clear.

Edit: I noticed that I was calling always the actors so I do it on “Event BeginPlay”*

Again thank you very much for your help!
Cheers.

So you are iterating the entire array of flappy bases, to figure out which one is “Other Actor” ?
Why not use “Other Actor” directly instead ?

Also why destroy it, if you are moving it back to start ?
You either destroy it and spawn a new one, OR move it back and leave it be. Your overlap event could be 2-nodes long :slight_smile:

IF you choose to destroy it, then the array “Out Actors”, that you built at BeginPlay for movement, will become desynchronized with what exists in the world. The destroyed platform will become a NULL pointer in the array, and the newly spawned platform will not be in it.
If you do that you need to refill the “Out Actors” array with a fresh result from “GetAllActorsOfClass” every time you destroy/spawn a platform.

EDIT: Actually I glanced too fast and I realize your logic is a bit more complex than that. You have two types of objects, and two arrays. I assume your goal was to figure out the type of object that “Other Actor” is when overlap happens. For that we use Casting. That lets you identify the class of an object, which is vital when working with events such as Overlap that give you abstract objects like “actor”. Here is an updated version :

1 Like

That node just make all more simple lol

Thanks a lot, I I’ve spent hours and hours understanding how to work with the actors in game and now I understand it much better. Thanks so much for the help! I’ll keep doing this “FlappyBird” attempt to keep learning.

Thanks again for your attention! You have helped me a lot!
Cheers!

1 Like