Isometric movement with wall collision question
![BRGKeen](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Hey all, I'm in need of some help on this one.
I have a game that uses an isometric viewing angle. Here is a link to a quick mockup picture so that you have an idea of what I'm talking about:
http://img41.imageshack.us/img41/3240/movementmockup.png
I need the player to be able to click anywhere on the screen, such as on that book shelf, and have the actor move to that bookshelf (even if it's just an image on the background and not an actor) without stopping when he touches the wall (I've been using friction to stop him, but I don't want him to stop I want him to keep going and stop under the touch.
I have the scene completely drawn and I add in a WALL actor to keep the character actor confined to the scene and where I want the player to be able to move him. I use a "MOVEMENT MAT" actor that is invisible so that when the player 'Touches' the screen the actor can move to that location.
What I need: I need it so that when the player touches the book shelf with their finger the actor will walk up, hit that wall, and then stop trying to move up the Y axis but just finish moving left on the X axis and stop right under where the touch was made, since the Y axis location is unreachable. This is just one example scenario since players should be allowed to touch anywhere and the character actor moves to the most ideal position as close to that touch as the scene allows.
Ultimate Goal: Player touches the scene and the actor moves to the most ideal position on the screen, closest to that touch location, that they are allowed to go and then stops when they reach it.
What I have already: Movement working without the interference of walls. I touch in any direction and the character actor moves and animates in that direction and stops. The problem is those annoying walls.
Hopefully that makes sense. I appreciate any help you can give.
I have a game that uses an isometric viewing angle. Here is a link to a quick mockup picture so that you have an idea of what I'm talking about:
http://img41.imageshack.us/img41/3240/movementmockup.png
I need the player to be able to click anywhere on the screen, such as on that book shelf, and have the actor move to that bookshelf (even if it's just an image on the background and not an actor) without stopping when he touches the wall (I've been using friction to stop him, but I don't want him to stop I want him to keep going and stop under the touch.
I have the scene completely drawn and I add in a WALL actor to keep the character actor confined to the scene and where I want the player to be able to move him. I use a "MOVEMENT MAT" actor that is invisible so that when the player 'Touches' the screen the actor can move to that location.
What I need: I need it so that when the player touches the book shelf with their finger the actor will walk up, hit that wall, and then stop trying to move up the Y axis but just finish moving left on the X axis and stop right under where the touch was made, since the Y axis location is unreachable. This is just one example scenario since players should be allowed to touch anywhere and the character actor moves to the most ideal position as close to that touch as the scene allows.
Ultimate Goal: Player touches the scene and the actor moves to the most ideal position on the screen, closest to that touch location, that they are allowed to go and then stops when they reach it.
What I have already: Movement working without the interference of walls. I touch in any direction and the character actor moves and animates in that direction and stops. The problem is those annoying walls.
Hopefully that makes sense. I appreciate any help you can give.
Comments
If you don't have a problem with that, you can accomplish this with the "move to" behavior and some carefully chosen rule conditions.
For instance - determine at which point the actor looks as though he has moved off the floor. In other words, if a user touches at the very top of the ceiling, you don't want your actor appearing to walk up the wall. Find that point, and use it strategically. Say, for instance, that it's 280 pixels. In your rule, include a condition ("touch.Y<280"). If touch.Y is > 280, then use the following alternative movement:
Move to X (touch.X), and Y (280).
The benefit of this system is you don't need any collide rules, or walls, or anything - the actor will simply move about the room normally. The room could actually be a background image, basically. On top of that, you could easily add a constraint rule that changes the height of the actor as it moves up and down the scene, so it appears to get taller as it moves to the bottom (closer), and shorter as it moves to the top (further away).
Let me know if any of that is unclear.
I don't know if that would be bad practice for some reason, I just know I've experimented and it works. Works well for simulating z-index as well.
@msones: I don't have a problem with that, except for an issue that may arise with my scenes being so diverse. What if a table were in the way of the actor? Ideally the actor (character) moves in a straight line toward the touch and can collide but "go around" the table.
I need the actor to make its way to a point closest to that touch location while moving around obstacles like a table or another character (NPC).
I think your solution would work, but I would have to adjust the X and Y for every contingency in every single scene and wouldn't account for hitting objects.
@Metronome49: I've tried this but for some reason the constrain is overriding collision. How did you get around that? That solves the bulkiness of the character's collision, but leaves the issue of the character being able to still get to the final spot after colliding with a wall and stopping at that spot rather than continually sliding.
It takes into account the same issue as I originally posted. The character hits the wall and isn't able to proceed on the X to the spot below the Y and stop because there's nothing telling the actor to do that. msone's idea works perfectly if the character was just in a box. I could set its boundaries and it works perfectly, but what if the path were not so cut and dry linear, etc.
Maybe it's called pathfinding, I'm not sure.
I hope that I'm making sense. Here's a video of Monkey Island doing something similar to what I want. Watch from 5:12 to 5:20 as the character navigates only the area of the game it's allowed to go, yet the player can click anywhere and the character will attempt to move to that spot.
I have a feeling it's going to take dozens of attributes each scene. "If on this spot, restrict movement only to Y=200" and once hits this spot "X to 30" etc.
How would I limit the range of movement to a range of X or range of Y?
Oh, I didn't have to solve that problem. I'm controlling with keyboard. I'm sure there's a way to use my method and get that, though. I think my method of collision detection could really help you in a point-click adventure.