#Will it always be the Sprite Parent
1 messages ยท Page 1 of 1 (latest)
yes bro, this is 2 wheel game, and this is the first wheel and the wheel got 8 sections, i want to do when this section called (PremioIT) (SpriteParent) etc.. be the win/reward do some transition to appear other button saying "Next Wheel"
Hm, that's still a bit unclear. Try shorter sentences.
How do you choose which item should be the prize? @lime ridge
The prize is with percentage xD
And i want when te prize was prem
that is prize win
It shows an effect and go to the second wheel
post the full script which selects the prize
Alright. I've skimmed through it.
I need a better definition of your initial question:
can i associate when the result of this wheel be this Sprite to appear one button??
Try to explain in multiple short sentences.
@lime ridge
here u got an very fast vid bro
i think you're going to understand better
its uploading wait please
As far as I have gathered, this should happen:
- Wheel spins
- Prize is selected
- User gets prize
- Next wheel spins
(Not from reading the code, but a general idea of what is happening)
yes is this idea
if user gets prize next wheel spin
if not
same wheel spin again
Yes. Which part are you having issues with?
when the user get the prize
dont skip to the second wheel
in the vid im starting by the end
and its everything ok
its just 1 spin on this wheel and go back to the first wheel again
Okay, so when the wheel is done spinning, and the prize is presented,
you want a new wheel to pop up, after the user clicks to collect the prize? @lime ridge
Yes
After he clicks to collect go to the first wheel on the vid that is supposed to be the last
but just when the prize that user gets on first wheel was the 50$
Is this the game's main scene, or is it loaded from a menu?
My first thought is that this wheel should be something you can invoke by a function.
If you have that, you can easily invoke it again, and even add parameters, such as conditions.
I'm just not sure if I can figure this out on my own. The code base is somewhat large ๐
Great!
and he makes this
Claim the reward that is on "reward scene" after spin the wheel and turn on Active every this GameObject's
Button Spin, Wheel, wheel arrow etc
Alright, so you could encapsulate all of this into a single function, though I'm not sure that's necessary.
If you do, that means you can invoke what the button does right now, by code, without actually clicking the button
I think that makes sense since you want to reuse this functionality at different points in the game
Hm and how can i do that
certainly
I tried to make this
Make this script get what the prize had got on the first wheel and by this or show the Claim Or ClaimCG
but something is not good here
In stead of using GameObject.SetActive directly from the OnClick
you make a function which does all of that in a single execution.
Then, you add that function to the button's OnClick, and you can use the function from other places.
this can not solve?
The script im using is this
i would need to change the action == 0
for prem
or noprem
not?
And the script knows what prize did the user get and if get the prize allows the button ClaimCG if not shows the button Claim
whoa...
hi spawn
Code - https://gdl.space/evabegaqav.cs
Video - #1084493284543565915 message (fixed)
ahh, gotcha
wrong video link lol
i'll try
Steve sent's this script
and u just copy and pasted it?
yes
why is the script named 1?
wtf
and u cant just put the script in there
wait
it has to be a gameobject thats containing that script
He is called OnButtonClick
Whuut
u just dropped the script in there
So where did i need to put it?
an empty game object (for the script to run)
it will be invisible. place it anywhere
yes i save
Show the script
ok good
did it
So we'll need to modify the example a bit
The example shows how you can Activate or Deactivate gameObjects in an array
You want to replicate these actions:
I put this
That's the example script I'm talking about
It is merely an example - not precisely what you need
Remove one of the arrays.
Rename it to WheelObjects or something
Remove the loops connected to the array you removed from the code.
Script should have no errors at this point.
.. not sure what the end goal is here.. im just seeing pointing out errors i catch lol
Spawn
sup
If I got this right, he just needs to encapsulate that button's actions into a public method, so he can call it several times, at different points in the game
the end goal is
when the user get the prize on the wheel 1
appear's a button "Go to second wheel"
mmhmm gotcha
Oh, a second button
on the vid i start on second wheel
and i spin it 1 time and appear the button back to wheel 1
and it goes
but on wheel 1 when i got the prize he stay appearing the button to stay on wheel 1
with a second button or not, i just want if the user get's prize on the first wheel go to the second wheel
if its by a button or a transition i dont care, i just want that the user goes to the second wheel
and i dont know whats the best way to do this..
the video is hard to follow... sorry, i mean i see the video but without seeing When you click the screen and without you telling me like at what part of that video the second button should appear its hard to know..
it looks like alot of it is working how it should.. so
bro*
u got most of it working.. i dont get how this is any different than that other stuff..
aight.. yup, i seen that part
and this button
which button?
bring me back to the first wheel again
ohh ok
so it is a button
yes it is
lol
clickable text ๐ต๏ธ
ok.. so when u press that button
he brings me to the start again
ok.. and is that not what u want to happen?
and i want that he brings me to the second wheel
ok ok.. so when u press that button why does it take u to the start?
do u call the code on the button click?
yea.. but do u call code to take u back to the start
^ this is the word button one?
i dont see anything there that would take u back to the start
unless ur ClaimReward() function does it
exactly
Where in the code is the action for when the text is clicked?
soo.. if thats why it happens why not change it so it doesnt happen?
yea?
yea.. sooo
thats why we talked about the parameter earlier
u can call the same function regardless if u win a prize or not..
and do different things depending on if u did or not
or if u pass in a 0 or a 1 for example
ok
i thought thats what this was all about...
wait
i will send
When i press the clickable text
he makes me this
stop the animation, reset the rotation of the wheel and destroy all reward display too
yea, that shouldn't send u back to the start of the game?
i dont see anything there that would
he makes this
when u press the button yea i see.. u set active all those objects
alrighty
soo... have 2 different buttons lol
the other button u can change out with WheelParent2
Wheelborder2
wheelarrow2
Yes i can
then just toggle whichever buttons u need for that situation
so after u press wheel1 button it disappears and then shows u wheel 2 button
no bro
which then does the same thing as wheel1 button but instead uses all ur wheel2 objects
idk if u explaining it again is gonna do good or worse tbh
yea.. ok and is that an issue?
or is that what u want to happen or what?
umm.. well where in the script do u determine if it was a prize?
u can leave the button disabled
and then at that part in the code enable it if its a prize
ya.. so just check the enum..
i mean, i dont even see the enum being used tbh
Sidenote: Both for-loops can use int i as long as they are not nested inside one another
i tried asking more questions to help me understand better, but just ended up adding to the pool of information, whether its helpful or not
and now im to the point where i lost all orientation ๐
Alright. Have you made any changes to the code during this conversation? @lime ridge
Rov go beast mode
nop
im missing something simple. cuz how could this be hard.. if u have an enum lol..
if enum == noprize { //enable the darn button}
Okay. You are going to do one simple thing:
Create a method that does what each button does.
One method for each unique button action
^ I see where u going with this
Use the example script from before (the one in the scene). Just rewrite it completely.
Create on cs in code??
Write C# methods that do exactly what each of your buttons do.
Once that is done, you will set the buttons to do those methods* in stead
this is better strategy anyway tbh
but my buttons are turning active by the Inspector and doing something who is in code
So u want i create a method with this
writing on c#
i can not make just a parameter , if enum = prem {enable button1} else {enable button2}
??
u can for example set those active in ur functions
make it easier to read instead of ur button enabling this and disabling that.. u can call a function instead..
inside that function u can do all those things...
Yes but the problem is that im very new in the coding life and im not sure what to do
makes for better readibility
public GameObject WheelParent;
public GameObject WheelBorder;
public GameObject WheelArrow;
public void OpenWheel()
{
WheelParent.SetActive(true);
WheelBorder.SetActive(true);
WheelArrow.SetActive(true);
}
public void CloseWheel()
{
WheelParent.SetActive(false);
WheelBorder.SetActive(false);
WheelArrow.SetActive(false);
}```
and this is the final project of school and i just need to make this and im very very close to give up to be serious
i mean... no ones stopping u lol..
coding isn't exactly something that u just start doing and know how it works
its gonna be difficult at first.. until u learn whats what
but anyways.. in this example i do the same thing u do with ur button
it enables this and this and this
but now we could just call 1 function
a script with methods that buttons can use
yes, for simplicity
structure is nice. Your script is a bit of a challenge with its size ๐
see now my button actually does 1 singular thing
but it actually does all this junk
public GameObject WheelParent;
public GameObject WheelBorder;
public GameObject WheelArrow;
public void OpenWheel()
{
WheelParent.SetActive(true);
WheelBorder.SetActive(true);
WheelArrow.SetActive(true);
}```
because that Function does *all* of that
now u can have a function do a singular thing for everything u wanna do..
ur buttons can call different functions from the same script..
that script could also be in charge of for an example enabling and disabling certain buttons when u want
Ok
and i will put the enum
here too?
to enable the button 1 if enum = prize
or not?
Rephrase the last two things. (I can't understand xD, Maybe I'm just out of juice)
So, i will make a script who going to got all functions of the buttons
and after this how i will connect the enum to know if is to show button 1 or button 2?
public void SpinWheel()
{
//bla bla you do some kind of logic
//bla bla find out if you won
//wonPrize = if(youwon);
if(wonPrize)
{
Won_A_Prize_Button.SetActive(true);
}
else
{
//do nothing
}
}```
yea thats the only logic missing
these are again just examples..
its in ur logic somewhere already.. u add things to a list or an array or something, i seen it
if u add anything to ur list of prizes, or something then u already know where to put ur logic
u dont have to even use the enum, i just happened to notice it.. if ur not really using it u can do it with a simple boolean or something
public bool wonPrize;
But im using enum bro...
if(rewardObject.CompareTag("Extra Spin Reward"))
{
OpenWheel();
}
i dont really see where u use it tbh.. and not sure how u use it
u may just use it to tell the prize what it can be.. not sure if it represents the prize u actually get
as the player if that makes anysense
Fix what can be fixed. Then get some rest. You already made all this. You'll figure out a way.
Have you not created this project by yourself?
No bro, this is an lucky spin wheel template, and i get im and im adapting it to my liking, because im making my last school project
And i change the wheel, wheel prizes etc
Well, your' super close.. But also really far..
ur missing some aspects of basic syntax and how the editor works to full get it all together
i suggest u go back and look into some really beginner tutorials to get ur bearings
but at the same time u sed this is END of school project.. and it seems to me ur just trying to throw crap at the wall until something works
that unfortunately.. isnt gonna be the best way to solve and figure this out..
Also little related tip: try to name things in a way that it makes sense to you as you read/ try to code it.. for example :
in this example the function is called ClaimReward
to me that implies there is a reward..
if theres always a reward then that name is fine..
public void ClaimReward()
{
playersReward = reward;
}```
if instead, for example u *may* or *may not* get a reward yet u still call this function
(which is also pretty normal)
then name would probably become something like `TryClaimReward`
```cs
public void TryClaimReward()
{
if(wonPrize && reward != null)
{
playersReward = reward;
}
else if(wonPrize && reward == null)
{
Debug.Log("We won but there's no prize");
}
else
{
Debug.Log("We didn't win.");
}
}
little helpful tip, that is if you're actually interested in learnin'
ofc im interested to learn
but i get this code on internet
and the code was made and working
so i want to make some changes
and like u se in the vid its everything ok just the button not associated with prize or not...
and this is fucking me up
From where did you get it btw?
ya, thats the part that makes me wonder.. thats a really really easy concept.. to check against a bool, or an enum or something... the system u have set up around it is more complex than that
but i dont think u know the basics enuff and thats why ur hung up on this one part
Technically, you have all the pieces needed to produce the functionality you want.
The bigger issue is that this is all a bit overwhelming to you, so it may take some time before you see how easily you could do it all.
u need to think thru ur code.. its not hard to turn off and on a button
u just need to figure out WHEN
u wanna do it
and then do it
agreed
its like right in front of u.. and the crap part is we cant just point at it and show u..
it requires either u to know the reasons/ systems and what they're doing or for us to explain it to u
but thats only useful after u know when and where in the code u wanna do it
Since you're so immersed in this project, and you show some promise, I think fixing the methods + buttons and then food + sleep will make you wake up with a solution.
Sleep is literally necessary to learn this stuff.
instead of relying on the buttons and the inspector to do everything u wanna do try to think of it like this:
have the script instead do everything u want it to do for each case.. SpinWheel(); ResetGame(); TryClaimPrize();
and then u just have ur buttons call ur bank of directions..
one button will call SpinWheel(); <-- then this takes care of the rest..
oh
the ClaimPrize button can check if u won a prize for example, if u did win a prize it can give the player the prize or something GivePlayerPrize(); and if you didn't win a prize then you could call ResetGame(), ud call everything u need, including but not limited to Enabling an Extra button for you to press.. or if u did.. it
but to make this i will need to change all the code
and im not able to change all the code im to bad coding bro...
thats the problem
thats how u should do it anyway.. the OnClickEvents are great
but i dont believe shoving all ur actions in there are a good way to go
its better to have collections of instructions aka your Functions
and have a button call 1 or 2 of them at most
I won't be able to fix this.. I thought it was something much easy to solve
theres many reasons.. but for example.. if ur turning on and off gameobjects all the time thru the Click event.. and then for some reason u need the code to know about one of those objects.. it'd been better to just do all that in a function in the script
then you'd have all the info and all the references u already need..
because its the scripts responsibilty to do anything (related to that particular thing)
sure u could.. and its pretty easy.. but its not as easy as adding one more OnClick event inside the inspector
and that proves my point exactly..
Yes i know u got certain
but i dont got the minimum experience to make this
thats the problem..
Yeah, if you had, we'd be done long ago ๐
The solution is in here if you manage to piece it together.
Good luck, bro โ
its alot easier to do this.. and call DoStuff(); in the button
than to instead have ur inspector look like this ^
This man makes games. Listen to his advice.
but yea, i must be getting to work speaking of..
like Rov said.. the solution is here..
Thats ok... im grateful for the help
all u need is a boolean.. and a gameObject.SetActive(true);
4 real
https://github.com/CTNeptune/SpinTheWheel and i get this spin wheel
and made all that i got right now
ok, ๐ i might look that over in my downtime