speeding up actor on collision
Village Idiot
Member, PRO Posts: 486
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
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
Is the actor travelling in just one axis (horizontal or vertical), or is it traveling at some arbitrary angle ?
That will work if travelling in a positive x velocity. You could do the same with Y positive velocity as well.
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..
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.
Demo file attached:
Right on the money @Socks! Thanks heaps for that! Interestingly it's starting to make sense to me.. Watching your demo is strangely hypnotic..