added a basic ball that properly inverts velocity when colliding with a world boundary. my balls are getting stuck on each other tho
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var speed: float = 5
|
||||
const _speed_mult: float = 200
|
||||
var _direction: Vector2 = Vector2(1.0, 0.5)
|
||||
|
||||
func _physics_process(delta):
|
||||
velocity.x = speed * _speed_mult * _direction.x
|
||||
velocity.y = speed * _speed_mult * _direction.y
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func invert_x():
|
||||
_direction.x *= -1
|
||||
|
||||
func invert_y():
|
||||
_direction.y *= -1
|
||||
Reference in New Issue
Block a user