Help with isometric movement

Hopefully I can get a look at this this weekend, I like your example, I think to help someone just looking at this, we might need some very simple examples, say

How to place one tile where you want it.
Same with a sprite.
How to move the sprite in the four directions.
How the offsets and spacing work and there effects

Hopefully I can help contribute some of them.

1 Like

This works really well, have placed a sprite, setting up the offsets, have a little problem when I change the col or row value to move the sprite, the sprite goes to the correct position but has gone slightly off track, think it must be the values I’m using for the grid size.

Will Post some pics and the routine I’m using as soon as I can

1 Like

Still having problems, my tiles are 64x32, the gdevelop grid is 64x28, if you look at my events, 1st i create a sprite at col 0, row 0, then at col 4, row 0 but the sprite has moved off centre of the tile.

image

It took a bit of experimenting. It looks like your tiles are a different ratio than the ones I used.
I used a grid of 132x66 (66/132 = .5 ratio)
Your grid is 64x28 (28/64 = 0.4375 ratio)

If possible, I would recommend you change the grid and maybe tiles. If that is not possible/feasible then you can modify the function.

You would need to change the line below from .5 to .4375 (This could be rewritten to automatically calculate it although it would be best to do the math once and save it to a variable) I know the function isn’t especially user friendly but my goal was just to try to find the formula. It needs some tweaking)

You would also probably need to change the other function to convert from ISO to 2D if you converted in the other direction. Although, I’m not sure if I ever converted that to use the whole offset setup. And I’m clueless on the needed changes. The offset and the conversion would take some time.

1 Like

You know when I woke up this morning it popped into my head it’s the tile aspect that’s wrong!, anyway, I have changed the tiles to the correct aspect ratio and it works perfectly, thanks!

Now I need to experiment getting a sprite to move in four directions continuously and just checking at intersections for valid directions

1 Like

Can I ask, do you think the best way to move the sprite is to just increase the col or row variable by say 0.1?

I need the sprite to move continuously but every time it has moved 32 pixels (which should put it at the centre of the next tile) to check the tile instance variables to determine which directions are available

It depends on how you want it to travel and what it’s traveling on. I don’t really have an opinion. I guess I don’t really understand the larger concept. I still like the linked pathfinder method although I never dug too deep into the whole cost system.

If you can provide more of your concept or process maybe I can suggest something. I currently have no ideas.

image
its almost like a isometric riff on pacman.
Each instance of the tiles are 64x32, each has 4 instance variables up, down, left and right, set to 1 if its possible to move in that direction, I want to move the knight sprite continuously and smoothly (not jumping 32 pix) to the centre of the next tile (32 pix), it checks which directions are available (i already have the routines for random, chase and flee modes) and moves in the direction chosen (i can do this), the problem i have is getting the sprite to change direction exactly at the centre as it starts overshooting.

I did try to record a video but my Linux Wayland desktop just keeps recording a blank screen.

Yeah, it’s difficult to stop perfectly and still look natural. I played around with something similar in a normal grid but isometrics adds a twist.

You need to almost ignore all of the tiles except corners and intersections. You’d move smoothly from turn to turn. For turns, I played with rotating around a point using the put around point but again, that was a regular grid.

It’s tough. There’s a struggle betwen accuracy, look and frame rate. Let me think about it. In the meantime, maybe someone might chime in.

1 Like

if I move just 32 pix stop check then move on, it works perfectly but you get a slight stutter effect, I will try the just checking at intersections and see how it goes, thanks!

1 Like

It’s difficult because the events aren’t completely in pixel to pixel sync with the movement. It might help if it plans ahead. The second it collides with a tile a decision should be made while it’s still moving. I would try to use permanent force whenever possible. I would also make sure everything is optimized. Lightweight conditions used to prevent more process intense events along with trigger once conditions when possible. Do as little complex math as possible. If an event isn’t needed it shouldn’t run on every frame.

I’m better when I can try things myself. I’ll mess around a little and see if I have any ideas.:bulb: I already have the test project that’s isometric.

How about this for a concept? You move the objects around with continuous force. When they hit a specific tile, you use a tween to move it to the center of the target tile. When the tween is done you can then reapply a force in a new direction. How you choose is up to you.

I’m not sure if this helps but it is a way to center the object.

The object moves at 80 pixels per second. When it collides with the target tile. In this case I used the arrow sprite. That’s not part of my concept. It’s just an easy way to visualize the process and pick a tile from the InitialTileGroup. It calculated the distance from the player current CenterX(), Y() to the center of the target tile (the tile that is in collision with the player and my arrow sprite) It removes the force and tweens the sprite to the center of the tile using the formula duration in milliseconds = (distance/speed per pixels) * 1000 (in this case the speed is 80 and we use 1000 to convert it to milliseconds)

My current test project. It’s automatic. You don’t touch anything.

source:

1 Like

What a great idea, I’ve tried using a tween before but it was stop/start, I never thought of combining the two, cannot wait to give it a go!

1 Like

Just an update, everythings working fine, little sprite guy is traversing his tiles in Radom mode with a nice spot on movement, thanks again for your help!

2 Likes

Hi,
i don’t seem to be able to get the Get2dfromiso function to work, have pasted below my events, is this the correct way of doing it?, if i enter row=0, col=0, it shows the correct values of 0, 0 , but if i have row=0, col=2 I get Row=-1, Col=1, even though it should be col=2, I’m sure it’s something i’m doing wrong?, the tile is placed in the correct position though.

I don’t see anything obviously wrong but sometimes it’s tough with just a small snippet. I don’t have the time to look into your code. Have a look at the new version and see if that fixes things.

From time to time, I’ve been working on my project. This is the most recent version. I changed the functions to use just x and y. The offsets, width and height need to be set just once at the beginning. The offset points to the top tile.

try me: The text on the left shows the x,y of the tile under the cursor. Clicking “move” draws a circle at each tile.

.
project files:

I’m still testing this but here’s my new version. I add actions to set the offset and grid spacing in one line instead of setting the variables directly. I need to switch all of the extension variables to a global structure. Changing that wouldn’t change the way the current expressions are used. Using global variables would mean the offset value would only have to be set once. I want to use a structure variable to make it less likely to interfere with project variables. The expression’s variable names are chaotic. That needs to be fixed. As well as the name of the functions.

I have 2 offsets, one for the iso grid tiles and one for the 2D grid in my project. I also added a number parameter, so you can either use the offset or not. I wanted to use true and false for the “use offset” but you can’t use Booleans as a parameter for expressions.

source:

1 Like

Wow, just keeps getting better and better, will give it a try, cheers!

2 Likes

I’ve been trying the latest version, works great, far easier without having to include the offsets all the time, the problem I had before is fixed, I wasn’t setting the iso grid points correctly, looking at the original primer, do you think the rotation thing is possible?not sure of its usefulness but would be fun!

1 Like