# How to check solid when rotated.

5 replies to this topic

GMC Member

• GMC Member
• 316 posts

Posted 13 January 2012 - 11:28 PM

How do I check if a solid is ahead, behind, left or right of me when rotated any degrees?

Edited by Supertoad25, 19 January 2012 - 04:23 PM.

• 0

### #2 Sirosky

Sirosky

GMC Member

• GMC Member
• 1323 posts
• Version:GM8

Posted 14 January 2012 - 12:15 AM

You're talking about strafing right? Like what you can do in FPS games?
• 0

### #3 Big J

Big J

GMC Member

• GMC Member
• 2818 posts
• Version:GM8.1

Posted 14 January 2012 - 12:29 AM

To strafe left, you'll be strafing in direction + 90; to strafe right, direction - 90.

```var strafe;
strafe = 2; //How fast to strafe
//Strafe left
x += lengthdir_x(strafe, direction + 90);
y += lengthdir_y(strafe, direction + 90);
//Strafe right
x += lengthdir_x(strafe, direction - 90);
y += lengthdir_y(strafe, direction - 90);```

Edited by Big J, 14 January 2012 - 12:32 AM.

• 0

GMC Member

• GMC Member
• 316 posts

Posted 19 January 2012 - 03:48 AM

To strafe left, you'll be strafing in direction + 90; to strafe right, direction - 90.

```var strafe;
strafe = 2; //How fast to strafe
//Strafe left
x += lengthdir_x(strafe, direction + 90);
y += lengthdir_y(strafe, direction + 90);
//Strafe right
x += lengthdir_x(strafe, direction - 90);
y += lengthdir_y(strafe, direction - 90);```

This is a little late, but thank you very much.
But I ran into another problem, the game shuts off when I kill another player...help?
• 0

### #5 Big J

Big J

GMC Member

• GMC Member
• 2818 posts
• Version:GM8.1

Posted 19 January 2012 - 04:58 AM

Are you calling instance_destroy() from within a destroy event? Are you calling screen_redraw() in the draw event? Is a script calling itself forever? In all cases, the result is infinite recursion which causes a stack overflow and ends the game without warning and without any visible error message.
• 0

GMC Member

• GMC Member
• 316 posts

Posted 19 January 2012 - 04:26 PM

Are you calling instance_destroy() from within a destroy event? Are you calling screen_redraw() in the draw event? Is a script calling itself forever? In all cases, the result is infinite recursion which causes a stack overflow and ends the game without warning and without any visible error message.

Okay, turns out I was telling Gamemaker to turn the event, when it's destroyed, into another event when I could of just did that in the step event.
So thanks very much for that post, it helped me figure out the problem, but, I need to know how to check solids forward, backward, etc. when rotated.
• 0

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users