I can't set up the collider for the Tilemap or Player
Asked Answered
A

3

0


On each wall element I added a polygon

I added CollisionShape2d to the cat (character)
I'm new to Godot and don't understand how colliders work here, I tried to create a second identical character, but it didn't collide with the main character

Aorangi answered 1/10, 2023 at 19:49 Comment(0)
D
0

The cat is being lerp’d in _process rather than moved by physics, effectively bypassing collision.

This might help: https://docs.godotengine.org/en/stable/tutorials/2d/2d_movement.html

Dicotyledon answered 2/10, 2023 at 7:15 Comment(0)
R
0

I would need to understand your setup better to say what is going wrong.

How are you moving your cat? Are you using a CharacterBody2D? What does your movement code look like?

Ridgeway answered 1/10, 2023 at 23:38 Comment(0)
A
0

Ridgeway
Hi, yes, I am using CharacterBody2d, my cat moves to the place where you clicked on the screen, here is my code:


extends CharacterBody2D

var speed = 2
var destination = Vector2()

func _ready():
	destination = position

func _process(delta):
	if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
		destination = get_global_mouse_position()
	
	if position != destination:
		position = position.lerp(destination, delta * speed)

Aorangi answered 2/10, 2023 at 6:9 Comment(0)
D
0

The cat is being lerp’d in _process rather than moved by physics, effectively bypassing collision.

This might help: https://docs.godotengine.org/en/stable/tutorials/2d/2d_movement.html

Dicotyledon answered 2/10, 2023 at 7:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.