Aligning a 3d mesh on a rotating 3d mesh

Godot Version

4.2.1

Question

I want to align the cactus to the ground


@export var cactus : PackedScene = preload("res://assets/scenes/cactus.tscn")

@onready var player : CharacterBody3D = get_parent().get_node("Player")

func _process(delta):
    var pos = player.position
    rotate_x(-pos.z*0.01)
    rotate_z(pos.x*0.01)
    player.position.x = 0
    player.position.z = 0

func plant_cactus():
    var cactus : StaticBody3D = cactus.instantiate()
    add_child(cactus)
    cactus.position = to_local(player.position)

Do you want to rotate a child or align to ground? Your question isn’t clear, and your title doesn’t match your description.

I want to be able to spawn a cactus, that is facing up relative to the player, but will rotate with the planet ground