# Rotating Rectangle Collision

#### RipRoarinBoogerBenis

##### Member
Currently I am using a script to handle box collisions, however I an realizing I need my box collider to a rectangle, and to be rotatable, as to better simulate the movements of a vaguely oblong tank without things clipping into other things. Unfortunately, I think this would either involve having to calculate the rotation vector and add it into the acceleration or possibly use two colliders with linked velocities and I am wondering if there's a simpler solution that I am missing.

This is the current code I'm using:

GML:
``````collisionVeloX= cos(angleDir*2*pi/360)*velocity;
collisionVeloY= -sin(angleDir*2*pi/360)*velocity;

xVelo = velocity;
yVelo = velocity;

if(place_meeting(x + collisionVeloX, y, obj_ow_nopass)){
while(!place_meeting(x+ collisionVeloX,y,obj_ow_nopass))
{
x+=collisionVeloX;
}
xVelo = 0;
}

if(place_meeting(x, y + collisionVeloY, obj_ow_nopass)){
while(!place_meeting(x, y+collisionVeloY,obj_ow_nopass))
{
y+=collisionVeloY;
}
yVelo = 0;
}

x+=cos(angleDir*2*pi/360)*xVelo;
y+=-sin(angleDir*2*pi/360)*yVelo;``````

I think I would need to do something like:

GML:
``point_direction(oldAngle.x,oldAngle.y,newAngle.x,newAngle.y);``
and then add that in to the current acceleration for the collision check.

I'm open to any solutions though.

#### robproctor83

##### Member
Not sure what your trying to do exactly, but there is an option for rotating masks. Where you set the mask to be precise, there is an option for rotated.

#### relic1882

##### Member
Am I missing something or is there a reason you can't set the collision mask on the tank to Manual, then Rectangle with rotation? That way you could specify the rectangle within your tank sprite you want to be the collision mask.

#### RipRoarinBoogerBenis

##### Member
Doing some quick tests, when rotating, the rectangle will just phase through the block instead of colliding. I'm assuming changing image_angle also changes the collision_mask when using rectangle with rotation ?