Parser Error: Expected end of statement after variable declaration, found Identifier instead

v4.3.stable.official

func _physics_process(delta):
	var current_location = global_transform.origin
	var next_location = nav_agent.get_next_path_position()
	var new_velocity = (next_location - current_location)normalized() * max_speed

line 4 is returning the error message in the title. If i remove normalized(), its fine. I dont understand, can you not use normalize inside variable declaration?

Because normalized is a function from Vector2/Vector3, you need to put a “.” before the function name:

var new_velocity = (next_location - current_location).normalized() * max_speed

oh my god, which the tutorial im following also of course does. thanks, i dont know syntax :stuck_out_tongue:

No problem, just mark the question as solved.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.