I have a juggling game in which you have to bounce a ball on a paddle and the score goes up, but I am new to Defold and need help in making the script work.
It depends on what you wish to achieve But if you are new, the best option is to at first follow a tutorial and then modifying it to suit your needs
Related topics (proving also itās really not that hard to search the matter, because almost the same question was asked in the topic below, so itās always better to try to find anything, unless you have a specific question that we will happily try to answer ):
Thank you very much for the quick response, I will try out these tutorials and see which one suits best for me!
I hope, this will help you to start with
If you will stumble upon anything problematic, let us know
Thank you very much! The community here is very helpful and polite!
P.S. Notice the video linked above is the 3/3 part in the turorial series, while the whole 3-part tutorial is just around hour or so, so I think itās worth doing it whole (also I made it, so if you have any feedback on it, let me know )
Alright, I will!
I have a question, when I send the message an error called ERROR:GAMEOBJECT: Instance āunknown:7522881751777254728ā could not be found when dispatching message āhelloā sent from main:/Paddle#Paddle_Movement shows up
Is it because I havenāt specified the instance in the script yet?
How you send the message? Where is your game objects where you want to send your message to?
It might be just wrong addressing.
For easiest addressing:
print("My url: ", msg.url())
in init() in the script, to which you want to send your message.
This is the easiest way to get to know the correct absolute address of this script (so recipientās addrress)
That way, you can use it to write correct address in msg.post()
, but please, read more about addressing:
Or if you prefer videos, I have another one for you!
I also have a library called Pigeon, that simplifies sending messages - in each recipient you must though subscribe to given message, but instead you donāt care about addressing - Pigeon just sends the message to subscribers (yep, thereās also a video about Pigeon on my channel, but enough of shameless plugs I think, google it ;D )
Is it ok if I send you the scripts?
This is my movement script, along with the msg.post score thing
local score = āgui#Scoreā
local speed = 250
function init(self)
msg.post(".", āacquire_input_focusā)
self.dir = vmath.vector3()
end
function final(self)
end
function update(self, dt)
if vmath.length_sqr(self.dir) > 1 then
self.dir = vmath.normalize(self.dir)
end
local p = go.get_position()
go.set_position(p + self.dir * speed * dt)
self.dir = vmath.vector3()
end
function fixed_update(self, dt)
end
function on_message(self, message_id, message, sender)
end
function on_input(self, action_id, action)
if action_id == hash(ārightā) then
self.dir.x = 1
msg.post(āScore#mainā, āhelloā)
elseif action_id == hash(āleftā) then
self.dir.x = -1
end
end
function on_reload(self)
end
I donāt have an enemy or score upper thing yet, so I just used on_input to send the message.
You have to have then a script āmainā inside āScoreā game object in the very same collection
( the same from which you have your object with script that sends this message )
I will try it thank you!
How can I add the gui script into the game object the option does not appear when I want to add a component file?
Iām so sorry if Iām being dumb right now, itās just that Iām new at defold, completing only the movement tutorial.
You have a great channel, that Godot vs. Defold video blew up, congratulations!
You should add the gui script to the gui component.