Godot Version
4.7
Question
Hi there, I came across the strangest bug. It has happened to me twice now.
I am currently trying to program a First Person Controller. I have acceleration and deceleration in it. I was tweaking it and noticed that when I change my acceleration value, even to a ridiculously high value, it doesn’t actually change.
Here in the code, I have it initialized as 20000000000, but when I print the value of acceleration, it only outputs 1.0.
Only when I change the name of the variable (and I changed the name of acceleration throughout the whole code) does it change to the value I initialized.
This happened to me before in the same file, but with jump force. I had to rename it to jumpVelocity (better name anyway).
extends CharacterBody3D
@onready var camera_controler: Node3D = $CameraControler
@export var maxSpeed:float = 10
@export var sprintMultiplier:float = 2
@export var airSpeedMultiplier:float = 0.01
##Accelartationin steps
var acceleration:float = 20000000000
@export var airAcceleration:float = 66
@export var decceleration:float = 100
@export var jumpVelocity:float = 8
@export var jumpGravityModifier:float = 1
@export var fallGravityModifier:float = 3
@onready var gravity:Vector3 = get_gravity()
@export var mouseSensitivity:float = 0.005
var mouseCameraInput:Vector2
enum States {Idle,Walking, Running, Jumping, inAir}
var state = States.Idle
var stateBefore = state
func changeState(newState) -> void:
state = newState
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
print(acceleration)
this outputs 1.0
extends CharacterBody3D
@onready var camera_controler: Node3D = $CameraControler
@export var maxSpeed:float = 10
@export var sprintMultiplier:float = 2
@export var airSpeedMultiplier:float = 0.01
##Accelartationin steps
var acceleration2:float = 20000000000
@export var airAcceleration:float = 66
@export var decceleration:float = 100
@export var jumpVelocity:float = 8
@export var jumpGravityModifier:float = 1
@export var fallGravityModifier:float = 3
@onready var gravity:Vector3 = get_gravity()
@export var mouseSensitivity:float = 0.005
var mouseCameraInput:Vector2
enum States {Idle,Walking, Running, Jumping, inAir}
var state = States.Idle
var stateBefore = state
func changeState(newState) -> void:
state = newState
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
print(acceleration2)
this outputs the 20000000000.When i change it back acceleration it outputs 1 again.
it might be usefull to know that acceleration was an @export value before.
Does anybody have an idea what the issue could be?