Whats wrong with this code?


I’m making a game similar to Batman games and I want to disable the movement so i can use the left thumbstick to do the dialog selection similar to the Fallout games

I set up this code

if talk_mode = false:
		var input_dir = Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
		var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()

	velocity.x = move_toward(velocity.x, direction.x * _speed, Speed)
	velocity.z = move_toward(velocity.z, direction.z * _speed, Speed)


Then I got this error:
Assignment is not allowed inside an expression.

whenever you try to report/ask a question, tell exactly which line has the error you got. it helps a lot to decipher which part is the issue.

Edit this line to if talk_mode == false:

A single equals sign means you are trying to assign a value to a variable, while a double equals sign means you are comparing two values to each other, which is what you want in this case.

1 Like

i was too focused on the other lines, while the error is pretty simple at the top line. this should do it