![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | giancoppola |
I was working on a simple movement test, and for some reason the player scene will randomly disspear when moving around
Printing the .visible property still returns true, as do all the movement variables
Only active script;
extends KinematicBody2D
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
var horizontalMove
var verticalMove
var velocity : Vector2
var speed : float = 200
var accel : float = 10
var friction : float = 10
func get_input():
velocity = Vector2.ZERO
horizontalMove = Input.get_axis("moveLeft", "moveRight")
verticalMove = Input.get_axis("moveUp","moveDown")
velocity = Vector2(horizontalMove,verticalMove)
func apply_friction():
velocity.x = move_toward(velocity.x, 0, friction)
velocity.y = move_toward(velocity.y, 0, friction)
func apply_acceleration(_amount):
pass
func _physics_process(_delta):
velocity = move_and_slide(velocity * speed)
apply_friction()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
get_input()
if Input.is_action_just_pressed("test"):
print($Sprite.visible)
Here is a sample scene - https://drive.google.com/file/d/1Z0JeC1SHJ57WRXCb9lENnLLF7kfnhKbo/view?usp=sharing
Am I missing something incredibly obvious here?
Thanks in advance,
Gian