How can i make Y axis snap points?

The title may be confusing but let me elaborate. First of all, I want to make it clear I’m not that advanced when it comes to using blueprints, but I have base knowledge and can understand code logic. I’m trying to make a bubble shooter game in ue5, so far I managed to make my arrow move left to right within a certain range, shoot bubbles from a designated place and made them stop when hitting the ceiling. Now I want to make them snap to one of 7 different Y values. I have the base concept, make a float array that contains the Y values and then determine where the bubble hits the ceiling. I managed to take the Y value of the ceiling but i cant wrap my head around on how to do the rest.

This is what i have done so far. At the end i take the bubble location to make sure it’s X and Z value stays the same. And from the wall (in which I forgot to do here) I take the Impact Point

1 Like

You need a function to find the nearest Y

and use it here

2 Likes

I will try this once I get the chance and let you know how it went.

1 Like

Thank you for your help this works just fine. If it isn’t a big deal could give me a few hints. Right now I don’t have a way to check whether any of my Y axis values are currently occupied. After the FindNearestY, I tried getting all actors of a class and from out actors got the actor location, and tried comparing the NearestY and the Y location of the ball and setting a branch, but to no avail.

1 Like

So you have 7 different Y values, you can make a bool array with 7 items. Each time you use a Y coord, you mark the bool array index as used.

You can modify the nearest function to do this, in fact.

You will need to deal with the fact that no space are left, also :nerd_face:

1 Like