I have a simple storyboard setup.
Main to menu to either levelSelection or options. levelSelection to level1,2,3, etc.
I get no errors if I do menu - levelSelection - level1.
When I go menu - levelSelection - level1 - levelSelection - level1 I get the "Attempt to call method ‘(somemethod)’ (a nil value)… "
I get the same error if I go menu - options - menu - levelSelection - level1
The method in question is “getLinearVelocity()” in cube:touch
in my level1.lua at the top I do: local helperFunctions = require( “helperFunctions” )
and in scene:createScene: cube = helperFunctions.createCube( 45, 15, 15 )
I found metatables to be connected with this sort of error when I researched it.
Is that something I have to implement?
Yes, you can bump, we just ask that you wait at least a day or two.
That is a good start to pointing out the problem. What is line 128 of your helperFunctions.lua file?
Most likely one of two things is causing this.
you have overwritten the object that you’re trying to get the linear velocity of. This includes having removed the object before trying to get the velocity.
I have 2 buttons for when I finish the level that remove it.
Retry that goes to a temporary scene, removes level1 and sends me back to it.
Exit that sends me to the levelSelection. In the enterScene section I do storyboard.removeAll().
Am I not removing the cube and restarting the level correctly?
Every time a cube is created it should do physics.addBody().
Is there a way to check if it isn’t?
Also, what I find weird is the error happening if I go to options as well, a scene that has nothing do to with that function.
Main - Menu - going to Options and back - levelSelection - level1.
The first time I load the helperFunctions module is in level1.
Why does the error happen in this case?
Yes, you can bump, we just ask that you wait at least a day or two.
That is a good start to pointing out the problem. What is line 128 of your helperFunctions.lua file?
Most likely one of two things is causing this.
you have overwritten the object that you’re trying to get the linear velocity of. This includes having removed the object before trying to get the velocity.
I have 2 buttons for when I finish the level that remove it.
Retry that goes to a temporary scene, removes level1 and sends me back to it.
Exit that sends me to the levelSelection. In the enterScene section I do storyboard.removeAll().
Am I not removing the cube and restarting the level correctly?
Every time a cube is created it should do physics.addBody().
Is there a way to check if it isn’t?
Also, what I find weird is the error happening if I go to options as well, a scene that has nothing do to with that function.
Main - Menu - going to Options and back - levelSelection - level1.
The first time I load the helperFunctions module is in level1.
Why does the error happen in this case?