#As you can see i can only move the same
1 messages · Page 1 of 1 (latest)
It looks like you're able to click on the jellies fine, is that using your previously linked TriggerScript?
Yes the 2 scripts linked are the ones used. Jelli clicks are working finally. I just cant change the movable object to be = the selected object. Instead its always the same waterjelly
How many Sauce scripts do you have? Is there just one or one per jelly?
1 pr jelly, one pr gople. However i only have one public variable which i declare jelly, and only one instance of these jellies are put into that variable
The issue then might be with line 12 of your TriggerScript
You're using FindObjectOfType which according ot the docs:
Returns the first active loaded object of Type type.
What if i inside Sauce script on mouse down makes currentgameObject = gameObject, and then in triggerscript try to move gameObject?
I just dont know how to write that
You'll need to store which jelly is the active jelly when you click on it. I don't think you've shared the code for that, i f you have it yet.
Yes, that's the general idea. Then when you want to move a jelly, you use the one you stored somewhere, rather than the first active loaded object, which will always be the same thing.
This is what i thought of doing, i just dont know to move that object in the trigger script. i added to line 11 and 16 https://paste.mod.gg/mdwlwvpmdwlx/0
A tool for sharing your source code with the world!
This is on the way to being right.
Because you have many Sauce instances, each sauce will have it's own currentSelectedMainObject which probably isn't what you want.
You might choose to make currentSelectedMainObject a static variable.
So that way it is shared by all instances of Sauce.
In the trigger then you can do this:
Sauce.currentSelectedMainObject.MoveObject(triggerTag);
Yes! I tried with chatgpt to make a static variable and i lost all movement, and couldnt get further
public static Sauce currentSelectedMainObject;
(edited beacuse you want a Sauce, not a GameObject)
I would suggest not relying on chatgpt
I realize that now. Chatgpt returned me this private static GameObject currentSelectedMainObject for the sauce script. Thats why it didnt work. Its just hard not to rely on it when you are new programmer
There are lots of ways of doing this kind of thing but this should get you going for now.
Hm i get some compiler errors. combining 2 scripts is not something i know a lot about yet. We even have a movedirection in the sauce script which confuses me.
These are the updated scripts:
A tool for sharing your source code with the world!
A tool for sharing your source code with the world!
You probably want that to be a Sauce not a GameObject, see above where I made an edit
Ahh i had to set currentGameobject = THIS. Thanks for your help Thom i really appreciate it. Its for my exam in Denmark