#I cant fix this eror code

1 messages · Page 1 of 1 (latest)

little briar
#

plese help i dont know what i am doing wrong

last flume
#

<@&1349109171240439858>

last flume
wooden pier
little briar
little briar
full wind
#

you can show the code part that causing error and show the node tree

little briar
#

Ok I will

full wind
#

and is the scene global or smth ?

little briar
#

I don’t know I just started learning so I am not sure

full wind
#

good gdwaiting

faint pikeBOT
#
Embedding code in discord messages
Inline Code

When you surround some words with single backticks like `this`, it will be formatted as code.

Code Blocks

You can also include code blocks by surrounding the code with three backticks. If you add "swift" then you will also get basic syntax highlighting:
```swift
print("hello world")
```
Discord will then show it as a code block like this:

print("hello world")
Upload

If your code snippet is rather long, you can upload it to a text paste site. One option that supports syntax highlighting for GDScript is https://bpa.st/

wooden pier
#

You can embed code into the chat so its more readable than a screenshot.

little briar
#

So if I ‘ ‘ to my code It will help

#

In chat

full wind
#

i mean just a part of code thats refering to that node and a node tree is enought probly

little briar
full wind
#

so it cant find a $Player node

#

it is on the same scene as the code ?

little briar
#

is this what you ment

full wind
#

it is named player

#

without big P

little briar
#

it is so should i rename all the player with Player

full wind
#

or just put small p in the code

little briar
#

i will try that

full wind
#

instead $Player - $player

wooden pier
#

Yeah, node names are case sensitive. You can have a player and a Player and they'll be considered two different things. Same goes with a lot of things.

little briar
#

diferent eror now

wooden pier
#

You forgot the 'n' in position

#

$StartPosition

little briar
#

haveing somone else to look over my code is so helpfull thank you i will test now

#

i changed it and its still eroring

#

and the old erors are still there with the new_game and the player

queen knot
#

Wka

#

Still having this issue?

full wind
#

welp

#

trying to resolve we all do

queen knot
#

If I am not wrong we have been in this for 2 weeks

#

What is the node start position?

full wind
#

the issue is the node is from diffrent scene

wooden pier
#

try replacing it with $"../StartPosition"

queen knot
queen knot
#

Or use the get_node method

full wind
#

yep

wooden pier
#

It looks like it's being called by the player though?

little briar
#

so what should i do i should replace somthing with somthing sorry

full wind
#

get_tree().get_node("/StartPosition")

little briar
#

were do i enter that

wooden pier
#

Replace your $StartPosition with that exact line

little briar
#

ok thank you

wooden pier
#

to be clear, you need to keep the full stop and everything after it.

little briar
#

should i replace all $startpositions

full wind
#

only the $startposition

#

leave .position

#

after it

wooden pier
#

If you're calling it anywhere else, I'd recommend swapping it with a variable that you can store the position in.

...
startPos.position = pos```
little briar
#

i replaced $StartPosition in both main and player and it removed one of the erors but now we have this one

full wind
#

wait

#

the start()

#

doenst need to get_tree

#

you can leave $StartPosition

#

like it was before

little briar
#

ok so i should revert it

full wind
#

idk wait

wooden pier
#

get_tree().root.get_node("/StartPosition")

little briar
#

i will try adding that

#

did i add it right

full wind
#

remove / maybe

#

tottaly not sure

little briar
#

i will test

full wind
little briar
#

full window

full wind
#

alright you can rever it to $StartPosition

#

make sure you apply get_tree.... to the player.gd

little briar
#

i was adding it to both

#

so i reverted both

full wind
#

sory for confusion

#

like player is in diffrent scene so it needs to get_tree.....

little briar
#

so i dont need to change main but i should add get_tree().root.get_node("/StartPosition") to player

full wind
#

yes

little briar
#

ok i will test

#

so this

#

to this

#

i tested this change and it erored again

#

the eror is also bringing me to new_game

#

Well I have to move locations so I won’t be able to test for a while but thank you for your help i don’t know why it’s not working well I will keep looking but if anyone has any ideas it would be greatly appreciated thank you

full wind
#

no problem

hearty flint
#

but getting it that way is incredibly clunky and error-prone. don't do that.

#

this is why, in the tutorial in the docs, the main.new_game function provides $StartingPosition.position as an argument to $Player.start

#

that way, player doesn't have to know about the existence of a StartPosition node, it just needs to be told by the main script where to go

#

but going back through and comparing to the tutorial now

#

your actual problem is that you're trying to set the StartPosition's position from the player script, using the value of pos that it just got from StartPosition's position

#

this code

func start(pos):
    position = pos

is meant to set the player's own position to whatever it's given as the pos parameter

#

so when the main scene script calls

func new_game():
    score = 0
    $Player.start($StartPosition.position)

it reads the position vector from the StartPosition node, passes that vector into the start function on the Player node, which then uses that vector - now just called pos - to set its own position

hearty flint
#

(but please do ping me if replying to me, so that i see it)

little briar
#

so what do i switch out i am sorry i am a litle confused