Cant move after changing positions


when i pick up that 3 coins i teleport but i cant move in that direction how do i fix that?

You’ll likely have to show more of your code…

If your ‘if coins == 3’ condition check is inside your update function, then it will be called every frame, effectively setting the position every frame as long as coins==3.

You might wanna change this function or the condition check so it only runs once.

forgot to tell that this is just basic body movement but i dont think it matters i just want to change position of my object

how do i make it call just once

Please post your whole script and if possible also a pic showing your node setup this script is attached to.

extends CharacterBody3D

var hasTeleported1 = false
const SPEED = 5.0
const JUMP_VELOCITY = 4.5

Get the gravity from the project settings to be synced with RigidBody nodes.

var gravity = ProjectSettings.get_setting(“physics/3d/default_gravity”)

func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta

# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
	velocity.y = JUMP_VELOCITY

# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector("a", "d", "w", "s")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
	velocity.x = direction.x * SPEED
	velocity.z = direction.z * SPEED
	velocity.x = move_toward(velocity.x, 0, SPEED)
	velocity.z = move_toward(velocity.z, 0, SPEED)

if coins.coins == 3:

func _teleport():

	position.z = 6

I don’t know your project setup, so I’m guessing a bit here:

It seems you want something to happen when the player collects a third coin (teleport).
Since the number of coins only changes when the player collects one, you don’t need to have this condition check inside your CharacterBody3D’s process function.

Instead I see you have a reference to coins that seems to keep track on how many coins your player has.
How about you move your condition check inside that coins script, specifically only to check every time the coins.coins value changes? That way, it won’t check every frame, but only when the player collects a coin.