How to make moving tentacles?

Discussion in 'Programming' started by Mick, Sep 24, 2016.

  1. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Hi! We started making a boss that should have about four tentacles attached to his back. They would move and wiggle randomly and sometimes sweep across the floor. How would one go about and make such a thing the best way? We are not using physics for anything yet but if it's the way to go then we could use physics. Spine is another option but we don't have a license for that. Greatful for help if somebody have found a solid way of doing this!

    By the way, it can look old school like classic games with connected circular sprites.
     
  2. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,441
    thats is a super braod question...
    the best way? it depends on what exact effect you are looking for?
    you could use bones, parent each section to each other... you could use a curve and draw along that.
    there are simply too many ways to do it.
    and for each of those ways, there are many, many implementations! each with pros and cons.

    Try something out. event if it doesnt work! just throw toghether whatever you can. show us, and then we can start helping you!
     
  3. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    I know it's a broad question, I'm just looking to get ideas. I just started experimenting with bezier curves, I'll see how that turns out.
     
  4. chance

    chance predictably random Forum Staff Moderator

    Joined:
    Apr 22, 2016
    Posts:
    795
    Parametric curves like Bezier will work fine. Even GM's built-in path functions will work. Updating the control points and re-drawing the path each step is fairly slow, but it's OK for starters.

    Do you want the tentacles to interact with other objects? If so, box2D physics works well for that. I've made some interacting tentacles by laying jointed fixtures along the curve path. That seems to work well.
     
    Mick likes this.
  5. One way to do it is like they did in some of the older SNES games, and have a series of circles act as the tentacle.

    For the moment, you need to envision the joints (the parts of the tentacle that are free to move) in terms of their arm moving plus and offsets in the perpendicular direction for the joints along that arm.
     
    Mick likes this.
  6. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    I'm testing with a bezier curve script now, having one gm path controlling the end point and one path controlling the "curve".

    That's not really necessary, normal collisions are fine I guess. I will look into jointed fixtures if I need to later but I think I can manage without them.

    That's exactly what I started doing, having good progress so far. :)

    Thanks for the ideas!
     
  7. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Zabicka, Yal, jackhigh24 and 3 others like this.
  8. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,892
    I made some tentacles for Skein:

    [​IMG]

    How I made them was to make a path with three points on it, and then make the path smooth and then set am x/y goto position for the top of the tentacle (point 3). I then lerp the end of tentacle to that point and repeat, and I also do the same for point 2 but to a lesser degree.
     
    Zabicka, NazGhuL, rytan451 and 5 others like this.
  9. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,539
  10. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,892
    @FrostyCat: Thanks for that, but... Maths is NOT my strong point and I don't have least idea how to even start applying those formulas to a game. Which is why I used paths. It's easy as they already have a smooth function, I already know how to use them, and I can easily draw stuff along them to create the tentacle effect. This is why I love GameMaker... :)
     
    KingdomOfGamez likes this.
  11. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,889
    I didn't look at the code he went off of, but I'd guess it's just a matter of redefining P1, P2, and P3 whilst leaving P0 (the anchor) intact.
     
  12. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    They are not actually moving randomly, I'm using the bezier script and x1,y1 are moving along one path and x2,y2 (the end of the tentacles) are moving along another path. I created paths for the tentacles in the path editor.

    (The end of the tentacles are separate objects that move along their paths and the tentacle object uses x,y from those objects for the bezier script)
     
  13. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,889
    You should take it up to the next order and implement 2 endpoints so you have more flailing.
     
    Mick likes this.
  14. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    I did that first but I got smoother movement using curved paths, I'm sure it can be made to look nicer still, but I'm the only programmer in my team and have a lot still to do. :) The tentacles will also attack the player (dive down and grab the player), the path movement will then pause and instead the end point will lerp towards the player.
     
  15. Tronco

    Tronco Member

    Joined:
    Jul 8, 2016
    Posts:
    18
    Sorry for necroposting, i'm really interested in this kind of effect, trying to reproduce the tail behaviour of R-Type's first boss.

    Could you please post some example code of one of the methods used to get this effect?
    The bezier curve script links are dead and i don't really have any clue on how to start coding something like that (very little experience in math i'm sorry :( )

    The only main difference (maybe it's a big one) is that in my case the sprites for the joints are not spherical, they are rectangular, so i need to take the image_angle factor in count to make them look "joined" togheter i think.

    Thanks
     
  16. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    You can use the path system in GMS to accomplish this. I created a simple example (using GMS1.4) that uses one path and moves the end position according to the mouse. To make it look better you also need to move the other points in the path.

    http://www.gamephase.net/files/linked/CurvedPath.gmz

    curvedpath.png
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice