Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

speeding up actor on collision

Posts: 382

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?

• Posts: 1,243

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

• London, UK.Posts: 12,453

@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 ?

• Posts: 784

@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.

• Posts: 382
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..

• London, UK.Posts: 12,453
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.

• London, UK.Posts: 12,453

Demo file attached:

• Posts: 382

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