Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | sphixy011 |
hello i am working on my project i was trying divide my speed variable (which is 300) by 4 its telling me the result and 0 i tried to convert it to float but its not working
here is my variables
export (int) var speed = 300
export (int) var jump_speed = -600
export (int) var gravity = 1500
export (float, 0, 1.0) var friction = 0.25
export (float, 0, 1.0) var acceleration = 0.25
onready var sprite = get_node("icon")
onready var collider = get_node("CollisionPolygon2D")
var velocity = Vector2.ZERO
and here is my function
func size_detection():
if $icon.scale == Vector2(0.125,0.125):
speed = float(speed) / 4.0
gravity = float(gravity) / 4.0
jump_speed = float(jump_speed) / 4.0
Does size_detection
run once?
exuin | 2021-04-03 15:34
yes I run it in physic_ process ()
sphixy011 | 2021-04-04 06:26
But that runs every frame! So your function doesn’t run once. You need to put it in the ready function or somewhere where it only runs once.
exuin | 2021-04-04 12:39
i put it in another place and it works thanks
sphixy011 | 2021-04-04 17:39