#Having issues with Ultimate Platformer Controller

1 messages · Page 1 of 1 (latest)

warm tapir
#

Im brand new to Godot Engine and I've been trying to use this asset library but I cant seem to figure out why it's giving me a "Invalid access to property or key "scale" on a base object of type 'Nil' error

I'm not sure exactly which of the code you'd want to see to be able to help me but the debugger points out these two lines

func _ready():
wasMovingR = true
anim = PlayerSprite
col = PlayerCollider

1-> _updateData()

func _updateData():
acceleration = maxSpeed / timeToReachMaxSpeed
deceleration = -maxSpeed / timeToReachZeroSpeed

jumpMagnitude = (10.0 * jumpHeight) * gravityScale
jumpCount = jumps

dashMagnitude = maxSpeed * dashLength
dashCount = dashes

maxSpeedLock = maxSpeed

2-> animScaleLock = abs(anim.scale)
colliderScaleLockY = col.scale.y
colliderPosLockY = col.position.y

timid anchor
#

Hello @warm tapir

#

What Godot version are you using @warm tapir ?

warm tapir
#

4.3

timid anchor
#

And version 1.0.2 for the ultimate platform controller?

warm tapir
#

yes

timid anchor
#

How have you contructed the scene?

warm tapir
#

Uhhh I have two scenes atm one that holds my character sprites+collider and another scene thats just a super basic square stage to run around in

#

If theres anything else I should mention please tell me

timid anchor
vapid whale
#

Try making sure that the Sprite is called PlayerSprite (casing matters).
My guess is that you missed a $ before the node's name. It should be something like anim = $PlayerSprite

#

$ is used to tell Godot to look for a Node with that name

warm tapir
#

thats what these are for no?

vapid whale
#

Yes, but you still haven't set them. You could have multiple sprites or collision shapes

warm tapir
#

oh so I have to put $ signs for all of those?

vapid whale
#

Not in this case, because they are already exposed. Check the right sidebar in the editor

warm tapir
#

exposed? I'm a complete baby at this stuff 😂

vapid whale
#

When you use @export, you tell the editor to show that variable in the inspector, so you can easily fill it out

timid anchor
#

You are exporting these

vapid whale
#

You probably didn't choose what Sprite to use

timid anchor
#

That implies you want to hook up those nodes via the inspector

warm tapir
#

oh oh okay

timid anchor
warm tapir
#

Thats what makes that GUI come up when I look at the characterbody2d thingy

timid anchor
#

It looks like you are using the sample project afterall

warm tapir
#

Yes I set those

#

Hmmm

#

In that example right everythings in one scene

#

maybe that is it

timid anchor
#

oh maybe you are not using the sample project, that is the one mega script that handles everything haha

warm tapir
#

no no I am trying to use this for my own thing

#

xD

timid anchor
#

That's fine, just trying to get context is all

warm tapir
#

Maybe this is actually the problem then, because I've my stage and character stored on different scenes cause when I add my player node as a child scene it doesnt let me assign the character and collider nodes

timid anchor
#

Does your player scene not have all the nodes you need to hook up?

warm tapir
#

it does

timid anchor
#

That should be fine then, no?

#

All the nodes are contained with the scene

warm tapir
#

oh hmm

#

So these all show as null for some reason even though I've definitely given PlayerSprite and PlayerCollider their information and anim/col are the same as PlayerSprite/PlayerCollider

timid anchor
#

What does your scene look like?

warm tapir
#

very basic atm

vapid whale
#

I think you didn't set the Nodes in the player scene, but did set them in other scenes?

#

Wait, no

timid anchor
#

Can you scroll this all the way down?

vapid whale
#

You did set them, but then set them to null

timid anchor
warm tapir
vapid whale
#

Remove:
anim = PlayerSprite col = PlayerCollider

warm tapir
#

okay lol

timid anchor
#

The mega script I was talking about

#

The sample project works

timid anchor
#

Something else is going on

warm tapir
#

yeah no i dont see a reason to make changes like that

#

especially when it works just fine in the sample

vapid whale
#

But the issue is that these nodes are null, right?

warm tapir
#

i tried it out of curiousity though

#

lead to the same error

timid anchor
#
  • The exports take in those two nodes
  • The script then assigns them to those variables (I guess as a protection from changing the export at run time)
#

Do you have any autoloads set up @warm tapir ?

warm tapir
#

It also called anim and col alot later in the codebase

#

Nope

#

you mean this right?

timid anchor
#

Right

timid anchor
#

Um, on that UltimatePlatformerController script, right click, View owners

warm tapir
#

wait right click where i dont see it lol

timid anchor
warm tapir
timid anchor
#

Hmm yeah idk

#

At this point I would start removing and adding the nodes back in

warm tapir
#

honestly

timid anchor
#

maybe zip it up and send it too

warm tapir
#

I might just cannibalize the sample project and see if I have better luck with it xD

#

It's not like I've done very much

#

I've only spent a day or two on this

#

well

timid anchor
#

It's up to you, I feel like it would either just work on my machine, or I would find some strange unconnected thing

warm tapir
#

a day or two before finding this script

#

what exactly would I be archiving?

timid anchor
#

Just the whole folder and all files except the .godot folder

warm tapir
#

I'll send it just for the hell of it anyways.

timid anchor
#

sure

warm tapir
#

uhm do I just post the link here or what

timid anchor
#

sure

warm tapir
timid anchor
#

got enough addons there? 😅

warm tapir
#

LMFAO

#

I was just clicking download on a bunch that looked interesting only later realizing that they overwrite the same files and stuff

#

And now I see that you should probably only download ones you'll actually use.

timid anchor
#

I think you gave me everything except for the scenes and script that I need lol

warm tapir
#

wait what

#

i realized I forgor to move the folders lol

timid anchor
#

If you restart the project, do you get any script errors?

warm tapir
#

oh yup

#

Failed to load parse error

timid anchor
#

So there were multiple versions of this same script

#

Probably not a good idea to throw in hundreds of addons to start with

#

the UltimatePlatformerController.gd was in there twice

warm tapir
#

hahahaha

timid anchor
#

and one of the player.gd scripts seemed to also be a replica of UltimatePlatformerController.gd

warm tapir
#

it throws a fit cause of that I assume?

#

I was meaning to delete those

timid anchor
#

After deleting all of those, putting back in that previously deleted code under _ready(): it worked properly

warm tapir
#

oh

#

well shit

#

LMFAO

timid anchor
#

I don't know how long it would have taken to arrive at this conclusion had I not seen the project 😄

warm tapir
#

Potentially days LMAO

#

Okay good to know it's something dumb and mundane like that

#

I'll try it after I come back from the store lol

warm tapir
#

That did indeed fix it