making a working slingshot

Hi all!
Trying to make a "slingshot" where the vertical speed of the "ball" is determined by how far back you pull it on the Y axis. I've constrained the speed of the ball to the attribute which is constrained to the Y axis of how far you pull it back from the starting point - but obviously this means that the further you pull it "back" (towards the bottom of the screen) the slower it goes because the Y number will be smaller. How do I make the attribute have an INVERSE relationship with the Y attribute? So the further you pull it back towards 0 on the Y axis, the higher the speed once its released? Thanks all

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    @jamesritchie@gmail.com said:
    I've constrained the speed of the ball to the attribute which is constrained to the Y axis of how far you pull it back from the starting point - but obviously this means that the further you pull it "back" (towards the bottom of the screen) the slower it goes because the Y number will be smaller.

    if you've constrained an attribute to 'how far you pull it back from the starting point' then the further you pull it back the larger the value of the attribute should be ?

  • Sorry so because "back" is actually "down" the Y value actually becomes SMALLER as you are pulling it towards the bottom of the screen (y=0). So I need to make it so as the Y value decreases the attribute actually increases (up to a certain point). I don't know how else to explain it sorry

  • I should have said "pull it DOWN" from the starting point because its played from a first person perspective if u can imagine that

  • SocksSocks London, UK.Member Posts: 12,822

    @jamesritchie@gmail.com said:
    Sorry so because "back" is actually "down" the Y value actually becomes SMALLER as you are pulling it towards the bottom of the screen (y=0).

    Agreed, but "how far you pull it back from the starting point" will always increase in value !?

    Maybe I'm misunderstanding how you have this set up, but if your starting point is - for example - y=200 and you pull it back by 150 pixels (y=50), then the distance from the starting point has increased ?

    @jamesritchie@gmail.com said:
    So I need to make it so as the Y value decreases the attribute actually increases (up to a certain point).

    You can have a value increase by the same amount another value is decreasing by simply subtracting the decreasing value from the first value.

    For example, if a value is going . . . . 10, 9, 8, 7, 6, 5 . . . (etc)

    And you were to subtract this from - for example - 20, the result would be 10, 11, 12, 13 ,14 15.

  • ok so i set the "sling power" attribute to

    75- game.Touches.Touch 1.Y

    But how do i make the relationship MORE speedy? Do I make the "75" value bigger or can I insert a multiplier on the TOUCH value? And how would I format it in writing?

    sorry if the way im writing doesnt make sense

  • SocksSocks London, UK.Member Posts: 12,822

    @jamesritchie@gmail.com said:
    But how do i make the relationship MORE speedy?

    Multiply the result by whatever you like would be the simplest approach.

    For example let's take your 75-y equation and assume the player starts their touch at y=75.

    So . . . at y=75 the equation will return 0

    As the player pulls the actor back towards 0 (bottom of the screen) the equation will return an increasing value, until at y=0 it will return 75.

    So you have a range of 0 to 75, multiply this by x2 and your range will now be 0 to 150, multiply it by x10 and the range is now 0 to 750 . . . and so on.

Sign In or Register to comment.