Hey guys,
I have been programming a game for a while and was wondering how I make it spawn at a certain position.
I can’t help much without more details, but putting the following code in the script attached to your Game Object (and replacing x, y, z
with the appropriate coordinates) should work:
go.set_position(vmath.vector3(x, y, z))
Ok, thank you for your time, I’ll try. Sorry for the lack of information, I was in a hurry.
It doesn’t seem like the code is read at all. How do I fix this?
Could you paste the code here? And could you add some print() to see if it’s getting near?
Have you added the script file as a component to some game object in your game collection?
Do you mean through main.collection?
Yes. On the image I can see that files are not saved (star indicator). If files are not saved, the changes are not visible to the engine.
I did a ctrl+s just now but nothing changed
Have you added the script file as a component to some game object in your game collection?
I have now got everything to work, it is just the coding now. Thank you guys for all the help! I’ll probably ask you for more tomorrow to be honest.
Great! So, what was the problem?
Note that the code in the screenshot is incorrect. It should be:
function init(self)
factory.create("factory#snigel_factory", vmath.vector3(500, 170, 2))
end
Without the )?
Use vmath.vector3(x,y,z) instead
Funkade ändå inte, ska jag ta bort min karaktär från main.collection först?