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