GameSalad

speeding up actor on collision

Village+IdiotVillage Idiot Posts: 485Member, PRO

So I've got a ball that I want to speed up (whilst travelling in the same direction) – when it collides with another actor. I've tried various things but can't make it work. This seems simple enough, alas, I am even more simple. Can anyone please help me here?

Comments

  • IceboxIcebox Posts: 1,434Member, PRO

    if actor ball overlaps or collides with other actor
    change attribute self.motion linear velocity x to self.motion linear velocity x + 10 or any value you want

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

    @monkeyboy simian said:
    So I've got a ball that I want to speed up (whilst travelling in the same direction) – when it collides with another actor.

    Is the actor travelling in just one axis (horizontal or vertical), or is it traveling at some arbitrary angle ?

  • ToqueToque Posts: 994Member, PRO

    @Icebox said:
    if actor ball overlaps or collides with other actor
    change attribute self.motion linear velocity x to self.motion linear velocity x + 10 or any value you want

    That will work if travelling in a positive x velocity. You could do the same with Y positive velocity as well.

  • Village+IdiotVillage Idiot Posts: 485Member, PRO
    edited April 27

    The actor that's travelling is a ball and it travels along both x and y – because it's travelling in whichever direction the player chooses to propel it. Metinx that means arbitrary @Socks.

    I've already tried what you suggested @Toque – and it didn't work.. unless I got it wrong.. I'll take a closer look just to be sure. I think the fact that it's travelling along x and y and is being propelled by the player could complicate things.

    I'm using vectorToAngle. I've got this sort of sling shot action happening to propel the ball..

  • SocksSocks London, UK.Posts: 12,725Member
    edited April 27

    @monkeyboy simian said:
    The actor that's travelling is a ball and it travels along both x and y . . .

    Then you will need to express the increase in speed as a percentage of the current X and the current Y speed, this will maintain the relationship between the two (to maintain the angle), so it should look something like this . . . .

    Change Velocity X to Velocity X * 1.5
    Change Velocity Y to Velocity Y * 1.5

    . . . . which will increase the actor's speed to 150% of the current speed.

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

    Demo file attached:

  • Village+IdiotVillage Idiot Posts: 485Member, PRO

    Right on the money @Socks! Thanks heaps for that! Interestingly it's starting to make sense to me.. Watching your demo is strangely hypnotic..

Sign In or Register to comment.