#is_on_floor() only works on right walls
1 messages · Page 1 of 1 (latest)
Any code sample? Are you working on 2D or 3D? Do you change the up_direction of your CharacterBody at any point?
it says 2d at tags
so i think 2d
2D, I don't even know how to change the up direction yet so no
Well, that only leaves one question. Do you have a script attached to your CharacterBody2D?
Wait? What is up direction supposed to be set to, it would appear to be decimals in both x and y somehow
I've now set it to 0,-1 and it still doesn't work
up_direction is set to Vector2(0, -1) by default. It's what "up" generally is
do you push the player character down with gravity? it would help to take a look at your code, it's hard to help with no information
what's your code
I just increase velocity.y
I'll send my code soon
`extends CharacterBody2D
@export var playerNum : int = 0
var left="l0"
var right="r0"
var up="u0"
var down="d0"
Called when the node enters the scene tree for the first time.
func _ready():
if playerNum==0:
left="l0"
right="r0"
up="u0"
down="d0"
elif playerNum==1:
left="l1"
right="r1"
up="u1"
down="d1"
pass # Replace with function body.
Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
#print(Input.get_vector(left,right,up,down))
pass
func _input(event):
if event.is_action_pressed("a0"):
# Your code here when the "A" button is pressed
print("pressed")
# For controllers, "ui_accept" is a common action name, but you can change it to match your project's input mappings.
func _physics_process(delta):
velocity.x = Input.get_axis(left,right) * 100
#print(Input.get_axis(left,right)*100)
#print(velocity)
print(is_on_floor())
#move_and_collide(velocity * delta)
if not is_on_floor():
velocity.y += 500 * delta
if Input.is_action_pressed("a0"):
velocity.y = -100
move_and_slide()
`
This
you only increase velocity when it's not on the floor?
i think you need to move into the floor to be on the floor
Yeah, is_on_floor() only returns true when it has collided against the floor on the last frame
Ok
you need to constantly increase the velocity.y
I think that's acceleration
500 is gravity
so you need to multiply delta
or else u add 500 every frame
I tried always applying it and it didn't work
Also it's more noticeable with more gravity but the player moves to the right while on the ground and the speed is proportional to the gravity
that's weird
Turns out the instances of the player scenes had different up directions
I think up direction was probably the issue after all
Thanks for helping
huh