GameSalad

Drawing a line from an actor

Hi all.. I'm thinking about trying to make a spider descend into my game screen from the top along a thread (line) which comes out from the back of the spider actor. I'm making an endless runner. I've searched around the forums and haven't been able to find anything solid on this idea. Can someone please help.

Comments

  • SocksSocks London, UK.Posts: 12,698Member, PRO

    Simply interpolate the size and position of the actor from to start position to the end position.

  • monkeyboy+simianmonkeyboy simian Posts: 421Member, PRO

    thanks @Socks I'm not so sure it'll be simple for me to do – as I'm me. I'll bang my head against your suggestion though.

  • monkeyboy+simianmonkeyboy simian Posts: 421Member, PRO

    @Socks I've been banging my head against your idea for less than 10 minutes and I think I might be making progress! I don't want to get too excited, but I think I'm learning!

  • SocksSocks London, UK.Posts: 12,698Member, PRO

    @monkeyboy simian said:
    thanks @Socks I'm not so sure it'll be simple for me to do – as I'm me. I'll bang my head against your suggestion though.

    I am assuming you are using an actor for the thread (let's say a 2 pixel wide actor) ?

    If that's the case then then it starts in one position, at one size, and then changes to another position at a larger size - all you need do is interpolate between these two values to have the thread grown in length (from a fixed top position).

  • SocksSocks London, UK.Posts: 12,698Member, PRO

  • monkeyboy+simianmonkeyboy simian Posts: 421Member, PRO

    here's what I've done – which works. Is that what you meant @Socks ?

  • SocksSocks London, UK.Posts: 12,698Member, PRO

    @monkeyboy simian said:
    here's what I've done – which works. Is that what you meant @Socks ?

    I'm not sure if the picture uploaded (or displays) correctly, it's just a single interpolate behaviour from what I can see ?

  • SocksSocks London, UK.Posts: 12,698Member, PRO
    edited March 2016

    Can you see the image I uploaded above ? The one with the short line and the long line ?

    Is that what you want to happen, for a short line to grow in length, while the top edge is fixed (unmoving) ?

  • monkeyboy+simianmonkeyboy simian Posts: 421Member, PRO

    yeah – it's just that. It works though. I've got a thin line coming down the screen from top to bottom. Is that different to what you had in mind?

  • SocksSocks London, UK.Posts: 12,698Member, PRO

    @monkeyboy simian said:
    yeah – it's just that. It works though. I've got a thin line coming down the screen from top to bottom. Is that different to what you had in mind?

    No, that's basically what I thought you wanted. I just don't see how you could have done that with a single interpolate (height) behaviour ? Unless the top half of the line is growing by the same amount, but going off screen (where it can't be seen) ?

    My suggestion was to use two interpolate behaviours to move and resize the actor at the same time, so the top of the thread does not move.

  • SocksSocks London, UK.Posts: 12,698Member, PRO

    @monkeyboy simian said:
    yeah – it's just that. It works though. I've got a thin line coming down the screen from top to bottom. Is that different to what you had in mind?

    Example.

    Place a 100 x 100 pixel actor into an iPad Landscape project.

    Position it at x512, y384 (centre of the screen).

    Now add an interpolate behaviour and set it to interpolate the actor's height to 400 pixels.

    Now add a second interpolate behaviour and set it to interpolate the actor's Y position . . . we don't want the top of the actor to move, we want it to only grow from the bottom, so the centre of the actor, which starts out at y384, wants to move down by 150 pixels, 150 pixels is half the increase in height (from 100px to 400px), so that the top edge never moves . . . . so set this interpolate behaviour to interpolate the actor's Y position to 234 (y384 - 150).

    Now we have an actor that grows in length, but with a fixed top position.

  • monkeyboy+simianmonkeyboy simian Posts: 421Member, PRO
    edited March 2016

    You were right @Socks – it was growing at both ends. I made it work properly using your method.

    I've got it to start from just off the top of the screen and then to grows down to about two thirds of the way down. I was actually going to try and make the final stopping position random, but I think I might have to use multiple spawners.

    This now leads me to the next challenge which is to attach an animated spider. I was thinking of trying a constrain attribute. Do you think this is possible?

  • monkeyboy+simianmonkeyboy simian Posts: 421Member, PRO

    I got that constrain working for my spider to be at the end of the line – though so far it stops at the mid way point. Still some work to do here..

  • monkeyboy+simianmonkeyboy simian Posts: 421Member, PRO
    edited March 2016

    @Socks – I'm beginning to think that maybe I'd be better off animating the whole thing as a single actor. The line and spider included – it seems clunky but I'm still unable to make it work using the above method.

    I've made a video which hopefully demonstrates what's going on – does this help?

  • SocksSocks London, UK.Posts: 12,698Member, PRO

    @monkeyboy simian said:
    I've got it to start from just off the top of the screen and then to grows down to about two thirds of the way down. I was actually going to try and make the final stopping position random, but I think I might have to use multiple spawners.

    Not sure why you'd need random spawners, admittedly I don't know how your game works or what it needs to do, but I'd just use the Random function to generate a value for the growth of the thread ?

    @monkeyboy simian said:
    This now leads me to the next challenge which is to attach an animated spider. I was thinking of trying a constrain attribute. Do you think this is possible?

    Like I say I don't know how your game works so I might be overlooking some aspect so might be completely wrong here, but the process (for everything involved) is really straightforward, you are just moving things from one position to another, if you have a spider at position A and want it to move to position B can you not simply interpolate the spider's position between the two ?

    You can of course use a Constrain if you wanted to - in which case you would be constraining the spider to the thread's Y position minus half the thread's height.

  • SocksSocks London, UK.Posts: 12,698Member, PRO
    edited March 2016

    @monkeyboy simian said:
    I got that constrain working for my spider to be at the end of the line – though so far it stops at the mid way point. Still some work to do here..

    I'm going to call that 'not working' :p :)

    I've not got access to GS at the moment otherwise I'd just make a quick demo of what I mean, but here's an image . . . .

    We have on the left the starting position, the thread is 100 pixels high and is sat at Y=650.

    On the right is the end position, the thread has grown to 500 pixels high and is now sat at Y=450

    So . . . . very simply for this to happen all we need to do is to interpolate the Y position from 650 to 450 . . . and interpolate the Height from 100 to 500 pixels.

    . . . . . . .

    If the spider sits at the bottom of the thread, then it starts out at Y=600 and ends up at Y=200. So for this to happen all you need do is interpolate the spider's Y position from 600 to 200.

Sign In or Register to comment.