Z
zilo
Guest
Hey all,
I'm a GM noob and have a couple of questions regarding collision.
I've been following the various YT tutorial for GM:S online and have been getting mixed results.
On one end some of them use built in physics for their collision and others programmaticly applying their collisions. I've found it easier to just use physics and move things with phy_position_x and phy_position_y ,but I know this isn't really a thing you should do (according to the GM manual).
I was wondering if I could get some advice on if I should be using GM's physics or writing my own collision stuff.
Here's my current top down movement code, I'm not really sure how to approach wall collisions with it.
This is in my Step event
I'm a GM noob and have a couple of questions regarding collision.
I've been following the various YT tutorial for GM:S online and have been getting mixed results.
On one end some of them use built in physics for their collision and others programmaticly applying their collisions. I've found it easier to just use physics and move things with phy_position_x and phy_position_y ,but I know this isn't really a thing you should do (according to the GM manual).
I was wondering if I could get some advice on if I should be using GM's physics or writing my own collision stuff.
Here's my current top down movement code, I'm not really sure how to approach wall collisions with it.
This is in my Step event
Code:
right_key = keyboard_check(vk_right);
left_key = keyboard_check(vk_left);
up_key = keyboard_check(vk_up);
down_key = keyboard_check(vk_down);
//Get the axis
var xaxis = (right_key - left_key);
var yaxis = (down_key - up_key);
// Get direction
var dir = point_direction(0,0,xaxis,yaxis);
//get the length
if (xaxis == 0 && yaxis == 0)
{
len = 0;
}
else
{
len = spd;
}
// Get the h spd and v spd
hspd = lengthdir_x(len,dir);
vspd = lengthdir_y(len,dir);
// Move
x += hspd;
y += vspd;