#How can i make my character go around certain tiles

1 messages · Page 1 of 1 (latest)

ionic nymph
#

Hello im looking for a good guide or set of docs that could help me workout how to make an isometric movement system.
I want to be able to press a button to select my character and have them move to where i press, but i want them to be able to move freely on the grid and not be bound by the tiles.

golden quartz
#

You can use the same logic as normal movement and just rotate the final result by 45º

ionic nymph
#

would i want to use CharacterBody2D or is there a better node for this?

golden quartz
ionic nymph
#

im just after something that can move to where i click on my tilemap, but i cant find any good sources on how to set it up

ionic nymph
#

Am still struggling to workout the movement not sure how to have the character be on the first layer of the tile map

#

Just want to be able to have characters I can select and move to points on the tile map to explore, gather, etc

ionic nymph
#

How can i make my character go around certain tiles

#
extends CharacterBody2D

var speed = 300
var click_position = Vector2()
var target_position = Vector2()

func _ready():
    click_position = position

func _physics_process(delta):
    if Input.is_action_just_pressed("Right_Click"):
        click_position = get_global_mouse_position()
    
    if position.distance_to(click_position) > 3:
        target_position = (click_position - position).normalized()
        velocity = target_position * speed
        move_and_slide()

i have been able to get a working movement system but am unsure how make it move around certain objects like ones i have marked as buildings

near bolt
# ionic nymph ```swift extends CharacterBody2D var speed = 300 var click_position = Vector2()...

You would need to implement some sort of pathfinding algorithm for that, first, you need to define a traversable space, you could do it using the TileMapLayers u have there, second you need to make an algorithm that uses that defined space to try an reach the goal position, like moving in the direction of the goal, until it reaches it or encounters an obstacle, if the later happens, you would need to move in another direction, and try again.

#

Since it seems this is your first time with pathfinding, i would recommend doing more research and looking up some tutorials, since this is quite a complex topic to simply explain it here.