Godot Version
V4.7
Question
Hi, I have a TileMapLayer as a scene, which has a area2D and collision shape. I’m trying to make it so that if the player jumps into the tile map layer they get boosted, increasing the height.
If I place the TileMapLayer in the main level, only one of the tiles work. The arrows on the left provides a boost to the player when it is jumped into, but not the arrows on the right.
Script for TileMapLayer:
extends TileMapLayer
func _on_area_2d_body_entered(body: Node2D) -> void:
body.velocity.y -= 100
Player script:
extends CharacterBody2D
const SPEED : float = 150.0
const JUMP_VELOCITY : float = -320.0
const GRAVITY : float = 1000.0
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity.y += GRAVITY * delta
# Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
var direction := Input.get_axis("move_left", "move_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
