Advertisement
desync1337

godot 4 nextbot

Aug 6th, 2023
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GDScript 0.44 KB | Source Code | 0 0
  1. extends CharacterBody3D
  2.  
  3. var speed = 15
  4. var accel = 2
  5.  
  6. @onready var nav = $NavigationAgent3D
  7.  
  8. func _physics_process(delta):
  9.  
  10.     var direction = Vector3()
  11.     nav.target_position = G.player.global_position
  12.  
  13.     await(get_tree().process_frame)
  14.    
  15.     direction = nav.get_next_path_position() - global_position
  16.     direction = direction.normalized()
  17.    
  18.     velocity = velocity.lerp(direction * speed, accel * delta)
  19.     move_and_slide()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement