#Need help with my script
1 messages · Page 1 of 1 (latest)
The reason it said nil is because you did var speed and never set anything to it, so it had no idea what speed was supposed to be.
it is set at line 63 in the headbob function
but i think it isnt getting called before movement happens
If you do @export var speed := 10, you can change the speed in the inspector, which you may find more convenient than editing the script.
But what do I do with my previous WALK_SPEED and SPRINT SPEED script?
maybe try and move that into the _process function instead of the headbob function
Either move _headbob up, or move the speed assignment into _physics_process.
_Physics_prosess?
give it a shot! you won't hurt the computer!
You should probably move it into _physics_process, because it doesn't seem to have anything to do with head bobbing.
I moved it, but how do I add the walk key?
it really depends on your code
it looks like when the "sprint" is pressed you are using the walk speed and when it isnt you are using the sprint speed
That's what I'm going for
What should I do with lines 67 and 72 then? It doesn't work.
send another screenshot
do you have an input for "sprint"?
no, let me bind it if I can find it
should I rename it to "shift"
you don't need to rename it at all
if it is set to something and it is being checked it should work like you want it to
It seems like no matter what I do, I still can't walk.
I don't know what I'm doing wrong.
No, I'm trying to learn as I make the game.
if you have time
i did this and it helped me understand how programming works a lot
I've been using this video https://www.youtube.com/watch?v=A3HLeyaBCq4&t=452s
In this video we create a first person character controller for Godot 4 from scratch. We also add a range of game feel features including headbob, sprinting, fov change, and inertia. This controller can be used for a variety of Godot 3D first person games, including FPS, horror, survival, RPG, etc. All of this code works with Godot 4.1.
Suppor...
it helped me go from tutorials to a more goal oriented method when progrmaming
usually my errors are from typos but this is a catistrophic issue.
@tranquil merlin other than the error, can something like this work?
yeah
the else statement would be better
no that wouldn't work sorry
so _ready will only run once at the very beginning
if you used _process or _physics_process, those get ran every frame or many times per second respectively
My speed commands are in process. But my input is somewhere else
Should I put them in one spot?
it can be in multiple places but const means it is constant so you don't need to set it in a function
the if statement should be called in one of the process functinons though
Then how should I use sprint to change the const speed?
like you have it, speed should be set to the value of walk speed and sprint speed
This is really confusing me, I have the values of both speeds. But I can't figure out how to change it in game.
Should I take a break from this for a bit?
if you want
i really would recommend a general programming course, the one I sent is free
it really helps in understanding why/how things work
I'm busy with high school and I only have a few hours to work on this.
I want to get as much progress as possible before I become an adult and do this full time.
if you want to make serious progress itd behoove you to learn such things then! an architect must understand the engineering before they can design a building!