T
tewpew
Guest
Hi guys! I currently involved in a project as a game designer (mostly art), but happens and now I have to do coding also. I don't have any programming background, so I'm struggling here, trying to make everything work. Here's my problem:
We have a character who is walking inside the room by clicking (click to move). We have some activated background objects (table, sofa, small table) which have collision with the character. Basically, player should be able to move within "green" area avoiding the "blue" objects. For the "red" chair player has to be able to move in front of it, but also behind it.
The main problem is, that almost every tutorials that I found are made for "WASD" controlling, and for me it's hard to switch to mouse controlling, because I don't understand the principle of movement clearly. Here's the code that I have so far:
mp_potential_step seems to work, but in a weird way (sometimes character just go through the objects). Using clamp so far was okay, but since we have a "perspective" room the line should be diagonal.
I would like to see any hints (or maybe even video tutorials) that can help me to solve this.
Thanks in advance!
We have a character who is walking inside the room by clicking (click to move). We have some activated background objects (table, sofa, small table) which have collision with the character. Basically, player should be able to move within "green" area avoiding the "blue" objects. For the "red" chair player has to be able to move in front of it, but also behind it.
The main problem is, that almost every tutorials that I found are made for "WASD" controlling, and for me it's hard to switch to mouse controlling, because I don't understand the principle of movement clearly. Here's the code that I have so far:
Code:
if (xx != mouse.none && yy != mouse.none){
move_towards_point(xx,yy,spd)
if point_distance(x, y, xx, yy) > 5 {
mp_potential_step(xx, yy, 0.5, false);
} else speed = 0;
}
else {
speed = 0;
}
x = clamp(x,34,203);
y = clamp(y,107,126);
if (direction >= 90 && direction < 270)
{
sprite_index = sprProtWalkLeft;
if (speed = 0){
sprite_index = spr_ProtIdleLeft;
}
}
else
{
sprite_index = sprProtWalkRight;
if (speed = 0){
sprite_index = spr_ProtIdleRight;
}
}
I would like to see any hints (or maybe even video tutorials) that can help me to solve this.
Thanks in advance!