FORUMS: list search recent posts

# Collision Detection Problems with rotation and movement of mc

FAQ   •   VIEW ALL
 Collision Detection Problems with rotation and movement of mc by Olly Beaon Jan 7, 2008 at 10:15:58 am

Hi,

I've come to a halt in working something out. After a long drawn out search for collision detection script i found one on this forum that is similar to what i want.

I have a boat which travels forward only (altered script for a moving car), you are able to rotate it left and right to chage direction you are travelling in. You aren't able to go backward.

There is land that you cannot travel (instance 'hit') over (as you're in the sea obviously ) and i have collision detection to make that possible. So it basically hits it and bounces util you change direction.

The problem i have - is that when you rotate to change your direction (with the reg point at the front of the boat) the rear of the boat goes ontop of the land.

I have tried changing my collision detection so that its bounding boxes rather than points that it checks, however - as soon as you rotate it no longer checks the collision of the bounding box.

I'm a bit stumped - i understand i would have to put a check where it's telling to rotate - but still havent come up with anything working

hope someone can point me in the right direction - thanks for any help in advance!

speed = 0;
}
onClipEvent (enterFrame) {
// make the car go forward
speed += 0.1;
// tells the car to slow down after the speed of 20
if (Math.abs(speed)>20) {
speed *= .7;
}
// you can change the rotation of the car to your desire
if (Key.isDown(Key.LEFT)) {
_rotation -= 15;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 15;
}
// here is where the hittest is for the boundary
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.hit.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}

i've already had a think about making the bounding box a circle. and bouncing back a little to cover the rotation - however the problem i have with that is as follows....

the boat has a long net on the back - the game is about catching fish (its for a museum before you mention it sounds rather dull!)

so when you turn the whole back of the net goes over the land. as the registration point obviously has to be at the front of the boat for more realistic navigation.

now you can see more of my problem.

i just need it so when you rotate the net hits the land in the same way the boat did and stops before going over it