What's the best way to make a modular floating enemy? [SOLVED]

Not favoritedFavorited Favorited 0 favourites
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • Hi guys!

    I've been trying to implement a modular shooter-style floating boss in my 2D platform game since yesterday, but I haven't been successful yet. I've tried using Physics' Revolute and Distance Joint, but it's been very buggy. I've tried implementing an algorithm (I confess, with the help of AIs) to keep the boss's sprites cohesive, also without success.

    My goal, as you can see in the image below, is to have the head either follow the player, but keep a good distance from him (~35 pixels), or circle around the top of the screen, while the player destroys its parts until only the head remains, which is the final target.

    Can anyone help me with this routine or have a similar example to share?

    Thanks in advance for your help. :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can try Follow behavior:

    dropbox.com/scl/fi/7cg90t64mgbzicjcr6ost/FollowSnake.c3p

  • You can try Follow behavior:

    https://www.dropbox.com/scl/fi/7cg90t64mgbzicjcr6ost/FollowSnake.c3p?rlkey=w55m1m9ormzhzhp8pf0hahh5u&st=wg6gg94k&dl=0

    Thanks!

    I'll test it! :D

  • You can try Follow behavior:

    https://www.dropbox.com/scl/fi/7cg90t64mgbzicjcr6ost/FollowSnake.c3p?rlkey=w55m1m9ormzhzhp8pf0hahh5u&st=wg6gg94k&dl=0

    Unfortunately, this routine didn't work for me in Construct 2. I had to make some adaptations, as C2 doesn't have the Follow behavior. :(

  • This is C3 forum. You should've mentioned that you use Construct 2. I spent time making that demo..

  • Sorry, dude. I use C3 too, but in truth I just have the C2 license. I tried to implement your routine on C2, with some change (due to Follow absence), and it wont worked. :(

  • In C2 you can make a similar chain with Pin behavior.

    dropbox.com/scl/fi/4o8syo1lzrehoefq46ocs/PinChain3.c3p

    It's a popular question - search the forum, there should be more examples.

  • Thanks, man. I know that behavior. I already test it, but unfortunately it didn't worked. :(

  • Since I'm a designer and not a programmer, I've been using AI to program, but I still haven't been able to get a functional routine in C2. :(

  • Now I tried using Array, but it didn't work. The head goes to the top left side of the screen and the vertebrae to the bottom right. I don't know what to do anymore. :(

  • R0J0hound Master, do you know what is happening here?

  • I'm almost there! :D

    I completely forgot to assign ID values ​​to the enemy's head and tail.

    I did this with the vertebrae in the loopindex, but I had forgotten about the extremities (head and tail).

  • Hi,

    No need to ever tag me. I don’t look at alerts and I skim over all the new posts when I visit the forum.

    I’m guessing you’re trying to do it by moving the head and having it leave a trail that everything else follows. One way to do it is add the head’s position to the front of an array, and just always position the body parts from an offset in the array. Finally you’d want a way to remove stuff off the back of the array when it gets too big.

    The main complexity here is the offset calculation. A simpler formula could be (self.iid+1)*30 to just have each part be 30 frames (or 0.5 seconds at 60fps) behind the part before it.

    (self.iid+1) gives 1,2,3,…etc
    (self.iid+1)*32 gives a distance of every 32 pixels: 32,64,…etc
    (self.iid+1)*32/100 if the head always has a speed of 100 this converts the distances to times
    (self.iid+1)*32/100*60 Finally this converts the times to frames. 

    So events would look like this

    Start of layout
    — array: set size to (0,2,1)
    — body: set offset to (self.iid+1)*32/100*60
    
    Every tick
    — array: push front head.x
    — array: set at (0,1) to head.y
    — body: set x to array.at(self.offset,0)
    — body: set y to array.at(self.offset,1)
    
    Array.width>6000
    — array: pop back

    You’d just move the head however you like. And at 60fps and the head moving at 100 pixels per second the body parts would be connected. There are likely many improvements to this idea but that’s the simple gist.

  • Hi,

    No need to ever tag me. I don’t look at alerts and I skim over all the new posts when I visit the forum.

    I’m guessing you’re trying to do it by moving the head and having it leave a trail that everything else follows. One way to do it is add the head’s position to the front of an array, and just always position the body parts from an offset in the array. Finally you’d want a way to remove stuff off the back of the array when it gets too big.

    The main complexity here is the offset calculation. A simpler formula could be (self.iid+1)*30 to just have each part be 30 frames (or 0.5 seconds at 60fps) behind the part before it.

    (self.iid+1) gives 1,2,3,…etc
    (self.iid+1)*32 gives a distance of every 32 pixels: 32,64,…etc
    (self.iid+1)*32/100 if the head always has a speed of 100 this converts the distances to times
    (self.iid+1)*32/100*60 Finally this converts the times to frames. 

    So events would look like this

    Start of layout
    — array: set size to (0,2,1)
    — body: set offset to (self.iid+1)*32/100*60
    
    Every tick
    — array: push front head.x
    — array: set at (0,1) to head.y
    — body: set x to array.at(self.offset,0)
    — body: set y to array.at(self.offset,1)
    
    Array.width>6000
    — array: pop back

    You’d just move the head however you like. And at 60fps and the head moving at 100 pixels per second the body parts would be connected. There are likely many improvements to this idea but that’s the simple gist.

    Sorry about that, but I was desperate.

    Thanks again for the great help! You're the man! :D

  • Hi,

    No need to ever tag me. I don’t look at alerts and I skim over all the new posts when I visit the forum.

    I’m guessing you’re trying to do it by moving the head and having it leave a trail that everything else follows. One way to do it is add the head’s position to the front of an array, and just always position the body parts from an offset in the array. Finally you’d want a way to remove stuff off the back of the array when it gets too big.

    The main complexity here is the offset calculation. A simpler formula could be (self.iid+1)*30 to just have each part be 30 frames (or 0.5 seconds at 60fps) behind the part before it.

    (self.iid+1) gives 1,2,3,…etc
    (self.iid+1)*32 gives a distance of every 32 pixels: 32,64,…etc
    (self.iid+1)*32/100 if the head always has a speed of 100 this converts the distances to times
    (self.iid+1)*32/100*60 Finally this converts the times to frames. 

    So events would look like this

    Start of layout
    — array: set size to (0,2,1)
    — body: set offset to (self.iid+1)*32/100*60
    
    Every tick
    — array: push front head.x
    — array: set at (0,1) to head.y
    — body: set x to array.at(self.offset,0)
    — body: set y to array.at(self.offset,1)
    
    Array.width>6000
    — array: pop back

    You’d just move the head however you like. And at 60fps and the head moving at 100 pixels per second the body parts would be connected. There are likely many improvements to this idea but that’s the simple gist.

    Your routine works very well! I've already implemented it here! :D

    My only problem is that the objects can't maintain a minimum distance between them, always coming together at a coordinate (that of the head, since they all follow it) when the head stops.

    Sorry to bother you again, but do you know how to fix this?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)