Metroid Zoomer like behavior; Enemies that go around a plane

I would argue you need that many points
In fact you would need only these 3


That 1st one in center on the bottom is for checking if object is touching any surface
2nd on the edge is for checking if surface just ended
3rd that in front of enemy is for checking will there be wall blocking enemy

NOW you ALWAYS move your enemy toward his angle
So now depending on if point 2 and 3 is in collision with wall
You either rotate it clockwise or counterclockwise

And for example if enemy is left from the wall going up means his angle is 90° or 270°
Depending on which angle layout you use

Then there is nothing in front of enemy but wall/surface ends
So you need to rotate enemy toward angle 0
Cause point 2 and 3 is NOT inside wall
Let’s go with bottom angle
Enemy angle = 270
Point 2 and 3 is not inside wall

Change enemy variable Rotate set to 0
Change enemy variable IsRotating set to true

And now while IsRotating is true you do not move enemy
When it is back at angle 0 you add force to enemy toward his angle

And you need to create events for all 4 angles here

Where if enemy is again moving toward angle 270
Enemy is on left side of wall
But there but instead of enemy going right you gonna need him to go left
Cause there is ceiling then you set Rotate variable to 180

Cause point 2 and 3 are inside wall

Now what if enemy is moving up and he is on right side of wall?
Well and now you throw into mix checking flipping horizontally and vertically enemy
I think you need only horizontally but whatever

Idea is build your logic step by step one wall scenario by one
And you will get it

It is nothing hard just like pealing potatoes
Someone needs to sit and do it

Once you get it working, you could use the profiler to compare the different methods.

Iive the idea of it having its own logic. I wonder though if you had a lot of them if they would eat up too many resources. Probably not. It would still be best to only activate them when on screen or near screen.

An interesting hybred might be if it remembered it’s path, so the next time it could just follow the path maybe with tweens or even the circular movement behavior.

1 Like

I’m probably saying somethinh without having read the full story…
but why to not adapt the sprite to the bounding box…so you gonna need probably 1 point instead of three…(or probably none?)…i mean as i suggested above it can be do with a raycast at bounding box that double the size of the bounding box and compare the two distances…but all other methods are in fact all great choices…intersting to see that this time there are so many ways to solve the problem…

…i’m just saying that if you don’t need that space u should fix the sprite and adapt to the bounding box…since well…there are already functions to check that…

if you really need a box to compare the two positions i would use another object…with the same size …extending the lenght…so if not in collision roteta by 90…thaz all…i guess…

…i dunno…i just don’t like unfitted sprites in general…i consider em not clean…They’ve caused me enough troubles to hate them

1 Like

@RMDB I just don’t want to change strategy now that I feel like I’m getting somewhere. If I reach a dead end or realize how easy and simple your suggestion is, I’ll switch. Currently I have hard time imagining how exactly your idea is implemented (I’m sure you know what you are talking about but as a beginner it’s really difficult to keep up without clearly written instructions with helpful images).

Thanks anyway!

1 Like

Don’t mind what i say .as long as it works and don’t cause any problems you’ll be fine

1 Like