I just started using Defold today and got the same error: “WARNING:GAMEOBJECT: Fragment has no meaning for this function: (null)”.
I found that this error comes from the platform script.
On line 6 and line 11, the get and set position functions there is a p parameter that is not defined and not needed as the id parameter is optional. When I removed those the errors were gone and everything still works.
In the chapter “animation and death” the text says: “Open the “hero.script” file and add the following functions:”.
I have added the functions at the end of the hero.script. But then the collision detection stopped working. Adding the functions before the update function fixed the problem.
Maybe this is normal behaviour in Lua. I never used Lua before. But if the order is important, it should be mentioned with few words.
@Asamak. You need to pay attention to and know the Lua scoping rules. The order of function declarations are important. For instance this won’t work:
function update(self, dt)
foo()
end
local function foo()
print("bar")
end
In the case above foo() must be declared before it’s used. This on the other hand works:
local function foo()
print("bar")
end
function update(self, dt)
foo()
end
If you have two functions that both need to call each other in under certain conditions you can forward declare one or both of the functions. This will not work:
local function bar()
foo() -- foo has not yet been declared
end
local function foo()
bar()
end
But this will:
local foo
local function bar()
foo()
end
foo = function()
bar()
end
You should make a practice of using local variables and functions as much as possible. If you don’t use the local keyword there’s a high probability of unexpected results unless you know exactly what you’re doing. If you don’t use local the variable/function will be globally available. If you use the same script on multiple game objects they will all read and write to the same variable, and that might not be desired. Read more about local variables here.
I had the same problem with the duplicated coins. The solution is simple. There is no such line of code in the tutorial. I found it only in the youtube video.
I had the same issue, and found I hadn’t linked the platform script to the platform.go or platform_long.go.
Select platform.go, right click in the outline, add component form file, select platform script.
I agree a “completed project” download to compare using the diff would be quite useful as one learns. (it is really good to have a diff tool, and git integration in the IDE)
The ‘Magic Links’ tutorial neglects to mention that you need to add the images to animation groups inside the atlas, or you won’t have any animations to choose from in your sprites…
A one frame animation is automatically made for you if you just add an image to an atlas so there is no need to create animation groups. But I’ll clarify that in the tutorial.
Hello there. Now I’m on the step 6 - Spawning platforms of the Tutorial. I’ve got a problem with a factories - when I build the game, there is no platforms. I checked everything over and over again, but can’t found problem. There is nothing in Error Log. Where can this problem be?
Did you attach the platform.script to the platform game object? If yes, could you please add a print() statement to the init() function to see that the platforms are created?
-- platform.script
function init(self)
print("hello from the platform!")
end
And if you see your print() in the console the next step would be to start printing the position, perhaps in update():
-- platform.script
function update(self, dt)
print(go.get_position())
end
If you see the platform moving, ie the position updating, then check if it is moving to the left, or does it look like it is falling? If it looks like it is falling then it’s because you’ve set the collision object on the platform to dynamic instead of kinematic. Dynamic collision objects cannot have their position modified through code. They will move according to the physics system, and in this case they will fall down instead of move left.