Problem trying to apply forced bounce angle

Hi all, I’m currently working on a game that requires me to create an un-natural bounce (for a ball) after a collision… The bounce is relative to the rotational value of another display object. The ‘object’ is rotated by a touch event, not rocket science. Something like this:

wall.rotation = wall.rotation +6

That happens on every touch event.

The ball reacts like this on the collision:

local function forcedBounceAngle() local speed = 400 ball:setLinearVelocity(math.sin(math.rad(wall.rotation-150)) \* speed, math.cos(math.rad(wall.rotation-150)) \* -speed) end

This gives me the bounce I want.

The problem is that, say I don’t apply the ‘rotation’ event to my ‘wall’ and just leave it where it is, the rotational value always resets to 0 after every collision, I have to apply the touch event to get a new rotational value.

I basically always want to return a relative rotational value, ragardless of whether the touch event was used, or not… If I rotated the ‘wall’ 45 degrees, the collision event occurs and I don’t rotate on the next cycle, I want the returned value to be still 45 degrees.

I’ve read somewhere that you can get rotational values as a percentage, or maybe I can get a delta value, but I’m really not sure.

Any help will be appreciated.

Regards

if i’m understanding this correctly then…

create a seperate variable to use within the math.rad(wall.rotation-150) so 

math.rad(SepVar-150)

therefore wall.rotation can reset to zero waiting for next touch or not, i assume wall keeps it’s rotated angle , and when ball collides it will use the SepVar value( which is not zero ).

Only thing to account for is some math to account for any future changes to wall.rotation to also alter SepVar the way you want it to.

T.

if i’m understanding this correctly then…

create a seperate variable to use within the math.rad(wall.rotation-150) so 

math.rad(SepVar-150)

therefore wall.rotation can reset to zero waiting for next touch or not, i assume wall keeps it’s rotated angle , and when ball collides it will use the SepVar value( which is not zero ).

Only thing to account for is some math to account for any future changes to wall.rotation to also alter SepVar the way you want it to.

T.