Ok, jump is working again, which means that this problem is solved. however climbing is still off, not sure if this a collision issue or an issue with walls needing to be labeled. If need be i can mark is as solved and then redirect you guys to the climbing thread.
It’s probably better to stay in this thread, since here’s the most recent version of your code.
About the climbing: Assuming you’ve applied the changes I recommended earlier, climbing should at least be somewhat working:
- You enter climbing state by pressing the jump button while the player is not on the floor and both raycasts are colliding.
- You exit climbing state when either:
- One of the raycasts isn’t colliding anymore. (In one case an automatic jump is performed.)
- Jump button is pressed while on the floor.
So, if you want anything changed about that, you have to tell us how you want it first.
yeah when i try to change move_and_slide_with_snap()
to move_and_slide()
the code breaks.
Though I don’t get why it should break from that, this isn’t needed anymore. It was meant for narrowing down the cause of the jump not working.
ok then im stumped as to why the climb isn’t activating
are you there?
Yes, I am.
Can’t say if that’s everything that needs to be changed here, but you definitely should delete the middle else statement, then put an else before the last is_climbing = false:
i tried applying that change but the player still doesn’t connect to the wall. im thinking it might be a collision issue.
are you getting notifications for this thread?
Does the player successfully enter the climbing state but moves incorrectly while climbing? Or does he leave climbing state too early (maybe immediately)? Or does he not even enter climbing state?
it might be that the player doesn’t enter climbing state. its kinda hard to show since i cant upload files. i can show you the code again if you need it.
Since you already have the is_climbing
variable, you should monitor that while testing, to see if/when it is getting changed.
how do you monitor a variable?
- While the game is running, switch back to the Godot editor.
- Above the scene tree, there should be two panels:
Remote
andLocal
. You need to click onRemote
. - Then, in the scene tree click on your player’s node ( = the KinematicBody that has this script). If that node was already selected, you might have to click on any other node first and then on your player node for it to update.
- Now the inspector should show you this node’s variables (=
Members
), so you can see the valueis_climbing
currently has in the running game. - (When you are finished, make sure to close your game (or switch back to
Local
) before making any changes in the editor.)
(I’m hoping there weren’t too many changes since 3.5 to this, I only know how this is in newer versions.)
ok i have the test scene running right now and the is_climbing
seems to just not activate. even when i turn it on it just turns back off. the most i can show you is this from the debug console
--- Debugging process started ---
Godot Engine v3.5.stable.official.991bb6ac7 - https://godotengine.org
OpenGL ES 3.0 Renderer: NVIDIA GeForce RTX 4060/PCIe/SSE2
Async. shader compilation: OFF
(-0.531593, 20, -3.049533)
(1.089826, 20, -2.100104)
(-0.68581, 20, -0.964214)
(-5.982446, 20, -10.187325)
(-10.240832, 20, -17.179157)
(-5.847421, 20, -19.126045)
Set Members/is_climbing
(-7.167348, 20, -18.671556)
(2.918355, 20, -0.941655)
(0.363098, 20, -1.115519)
Set Members/is_climbing
(5.138347, 20, 0.083503)
(-0.190393, 20, -2.329873)
Set Members/is_climbing
(-0.100645, 20, -1.165161)
(2.597992, 20, -1.371697)
--- Debugging process stopped ---
Okay, can you show the current version of your climbing()
function then? (This should be the only place where is_climbing
is getting changed.)
And maybe describe in which exact situations you want the player to enter climbing state?
#climbing
func climbing() -> void:
#check if player is able to climb
if wall_check.is_colliding():
if still_on_wall_check.is_colliding():
if Input.is_action_just_pressed("jump"):
if is_on_floor():
is_climbing = false
else:
is_climbing = true
else:
#if player is at top of a climb, boost them over the top
jump()
yield(get_tree().create_timer(0.3), "timeout")
is_climbing = false
else:
is_climbing = false
if is_climbing:
#if player is climbing disable gravity
gravity_active = false
max_speed = climb_speed
direction = Vector3.ZERO
gravity_vec = Vector3.ZERO
#sticks player to the wall
stick_point_holder.global_transform.origin = wall_check.get_collision_point()
self.global_transform.origin.x = stick_point.global_transform.origin.x
self.global_transform.origin.z = stick_point.global_transform.origin.z
#move player relative to the walls normal
var rot = -(atan2(wall_check.get_collision_normal().z, wall_check.get_collision_normal().x) - PI/2)
var f_input = Input.get_action_strength("forward") - Input.get_action_strength("back")
var h_input = Input.get_action_strength("right") - Input.get_action_strength("left")
direction = Vector3(h_input, f_input, 0).rotated(Vector3.UP, rot).normalized()
else:
gravity_active = true
here you go.
I have to ask once more then: How do you want the player to enter climbing state?
i have 2 ideas, one is for the jump to transition into the climb, the other is a prompt to climb. I want to do the former because 1. its just more natural. 2. being prompted to climb every time would probably get very annoying.
did you get the notification?