This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi.
Running into an issue that I cant find a fix for :( The problem is I have two objects, a wall and the character but I want to add another wall and am having issues with the code for collisions, I need to make it so that my character acts the same when colliding with either of the two walls wall but not sure what to add in the code to achieve this. I am still new so this might even be a noob question :)
Current character code (using a step):
//Get the player's input key_right = keyboard_check (vk_right) ; key_left = -keyboard_check (vk_left) ; key_jump = keyboard_check_pressed (vk_space) ;
//React to inputs move = key_left key_right; hsp = move * movespeed; if (vsp < 10) vsp = grav;
if (place_meeting(x,y 1,obj_wall)) { vsp = key_jump * -jumpspeed }
//Horizontal Collision if (place_meeting(x hsp,y,obj_wall)) { while(!place_meeting(x sign(hsp),y,obj_wall)) { x = sign(hsp); } hsp = 0; } x = hsp;
//Vertical Collision if (place_meeting(x,y vsp,obj_wall)) { while(!place_meeting(x,y sign(vsp),obj_wall)) { y = sign(vsp); } vsp = 0; } y = vsp;
Subreddit
Post Details
- Posted
- 8 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/gamemaker/c...