Hi
How would you recommend creating enemies like this:
Thanks
Hi
How would you recommend creating enemies like this:
Thanks
Your idea probably works at least in some scenarios. Still, it looks a little troublesome. I don’t know, it comes off as a little tacky.
But thank you! I appreciate this a lot.
Does anybody have better ideas?
Have you tried the Curved movement behavior?
https://wiki.gdevelop.io/gdevelop5/extensions/curved-movement/
I haven’t use the behavior that much. You can import an SVG to follow or create your own path.
This creates a path with 3 points. The Enemy moves in a square. The beginning position of the object is the 1st point of the square(I think) . The points are add relative to the previous point. So, 200,0 would add a point 200 pixels to the right of the previous or 1st position.
I used the behavior based on speed.
I set loop to true. So, it moves and loops without any other events. It should probably be disabled when not on screen. IDK.
My other idea was to create an obstacle with custom points and then create a path for the behavior based on the points. That would make it easier to setup. Define points, place the obstacle and then create paths based on the custom points.
The most efficient way code wise is purely with variables and using an array to record the corners relative to the start x and y along with ‘angle’ and a ‘step’ variable to step through the array. add to the x and y rather than using force so that you can reach corner points exactly - but this isn’t very gdevelop! and user friendly
An array would be a pain to create although, if it was relative, it might be easier to reuse. Give the object directions like 5,0 would tell it to move 5 pixels to the right. That way, the array could be used regardless of where the object was. It could all be put into a prefab object and just dragged and dropped.
I also, think if the object was 1 object then custom points could be used. You could then move or tween from point to point.
As a challenge, it would be interesting to try to give the crawling creature some autonomy. A point is inside or two or maybe ray cast could probably allow it crawl around the outside of an object by itself. IDK how efficient that would be but it would be an interesting challenge.
For simplicity, I prefer the curved movement behavior. That could also be put inside a prefab to make the object easier to place and duplicate.
At first look, i think that Keith is right. It’s long but easy to put collision points all around obstacles to follow.
Then, by evenements, you must move your saw following next point.
A+
I like Keith’s idea.
I’d probably just use a single object with an arrow pointing to the right. Then rotate it in whatever direction you want the enemy to move in.
I’d place them around the map where I want the enemy to start the direction change, and have an event that checks for collision, stops all forces, then applies a permanent force in the angle of the arrow object’s rotation.
i did this wih 1 raycast pointing on the ground.
if the raycast (tollerance) is not in collision turn the obj.but your columns will require more tuning…(prolly another raycast pointing ahead)
it’ll sick on any surface.
i should have a thread on slopes…somewhere
or - just to muddy things further. this is another thing that kind of works. Points on the corners of the object that you’re going round numbered 0 to 5. and link a variable and force to them. but you need the origin and center at the bottom left corner of the thing that going round it
actually no you dont need the points at the bottom left - they can be bottom middle and it works - looks ok
I am reading trough all ideas here and only yours seems like reasonable solution
Where i agree with points yet i would argue over points on walls
Points should be on object itself
And 2 or 3 under object to detect surface and 2 on sides one on left one on right to detect walls
And now whole logic could be applied to each enemy object
Where they could be dropped anywhere on the map and they would work on their own without messing up the map itself
i did try that - but couldnt get it to work for some reason - cant remember why though!
i remember now - its because of the L shape collission mask
That is why you need 3 or 2 points below enemy for detecting surface
Like did it ended or not
And 2 more on sides of enemy one on the left and other on the right
To detect obstacle in front of it
Actually you would need only one on side which would be front of enemy
And then 2 on botom
And that would give you all you need to detect whatever you need
Where turning should be done with tweens i guess
Or by adding/subtracting some value to enemy angle if its not equal to 0° 90° 180° or 270°
I couldnt get it to work that way as you needed two objects to create the L shape and as ever with point not inside multiple objects - computer says ‘no, which one?’ and my brain collapses!
By then you do not invert condition for checking points
You need to add new condition type NOT in serchbar
And add it
And under it you put your point is inside object condition
Which should not be inverted
IF it don’t work for multiple you make variables for each one and make each separate event
And now you can literally detect if something is ahead and if something is below enemy
It is a little bit of work and looks complex
But doing it step by step and testing it on each step
That will be most efficient way to achieve it
Cause you will only do it once
It will apply to all enemy objects and you will not to modify your map each time you want to slap new enemy there or add/remove parts of your map
@VALO - try @ZeroX4 's method above as it should be the most applicable to all situations and shouldn’t use too much processing. if you can get it to work - i need to go switch off.
Thanks everyone.
Here’s what I did.
Then I – somehow – managed to create my very own behavior! I added it to the enemy object.
Here are the events of the behavior:
Lastly, in the scene events, I run the behavior every frame:
It works great at the moment. I’d be surprised if I don’t run into any problems in the future but this is promising.
Benefits of this solution:
EDIT: okay it still has some major problems but I think this is the way to do it. I just need to fix some conditions…
Cool - when i tried to do something similar with points pretty much how you have them there, it wasnt working as i was adding 90 to a variable and rotating instead of how you’re doing it there and hard turning it 90. It would have worked had i turned off the point checks while it was rotating - in retrospect. creating a behaviour is still on my to do list! - nice job!