Characterbody3d "fakes" increase in velocity when i try to increase it externally

Godot Version

4.2.1 stable


hello! been having this really weird issue where i seemingly cannot increase the real velocity of a ball (characterbody3d) using code external to the ball. when i was debugging the problem, i discovered that i can in fact increase the velocity of the ball, but only within its own script. trying to increase it outside of its own script will for some reason only increase the velocity that’s printed in the console, but not the actual velocity of the object?

my ball script right now looks like this:

extends CharacterBody3D
var speed = 0
var speed_old

func _physics_process(delta):

var collision = move_and_collide(velocity * delta)

if collision:

	if collision.get_collider().name == 'right' or collision.get_collider().name == 'left':

		velocity.x *= -1


	if collision.get_collider().name == 'up' or collision.get_collider().name == 'down':

		velocity.y *= -1


and for my player script, i have these two blocks of code that are supposed to make the ball move, which neither actually work besides printing what the velocity should be:

func _physics_process(delta):
	if Input.is_action_just_pressed("taunt"):

			Ball.speed += 1

			Ball.velocity.x = Ball.speed



func _on_swing_light_body_entered(body):
		print('ball detected: ', Ball.speed, ', ', Ball.velocity)
		Ball.velocity.y += 5 

what im trying to achieve is having the player be able to influence the velocity of the ball, ideally through the area3d node i have connected to it. the taunt input increasing velocity was also just to test it since that worked within the ball script, but it doesn’t in the player script above

solved my problem! turns out that when i was referring to Ball, it was referring specifically to the autoloaded node, and NOT the node i actually wanted to control that was actually within the scene

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