#Will it always be the Sprite Parent

1 messages ยท Page 1 of 1 (latest)

lime ridge
#

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"

upper thicket
#

Hm, that's still a bit unclear. Try shorter sentences.

How do you choose which item should be the prize? @lime ridge

lime ridge
lime ridge
#

And i want when te prize was prem

#

that is prize win

#

It shows an effect and go to the second wheel

upper thicket
lime ridge
#

its all this code bro

upper thicket
#

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

lime ridge
#

here u got an very fast vid bro

#

i think you're going to understand better

#

its uploading wait please

upper thicket
#

As far as I have gathered, this should happen:

  1. Wheel spins
  2. Prize is selected
  3. User gets prize
  4. Next wheel spins
#

(Not from reading the code, but a general idea of what is happening)

lime ridge
#

if user gets prize next wheel spin

#

if not

#

same wheel spin again

upper thicket
#

Yes. Which part are you having issues with?

lime ridge
#

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

upper thicket
#

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

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$

upper thicket
#

Is this the game's main scene, or is it loaded from a menu?

lime ridge
#

What

#

main scene was this

upper thicket
#

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.

lime ridge
upper thicket
#

I'm just not sure if I can figure this out on my own. The code base is somewhat large ๐Ÿ˜…

lime ridge
#

The wheel

#

is invoked

#

when i click on the button

upper thicket
#

Great!

lime ridge
#

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

upper thicket
#

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

lime ridge
#

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

upper thicket
#

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.

lime ridge
#

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

keen estuary
#

whoa...

lime ridge
#

hi spawn

keen estuary
#

hello real

#

is this a new issue?

lime ridge
#

no its the same

#

maybe better talk on the other topic no?

upper thicket
keen estuary
#

ahh, gotcha

lime ridge
#

im too close i think spawn

#

can u help?

upper thicket
#

wrong video link lol

keen estuary
#

i'll try

lime ridge
keen estuary
#

and u just copy and pasted it?

lime ridge
#

And i associate him to a new button

lime ridge
keen estuary
#

why is the script named 1?

lime ridge
#

wtf

keen estuary
#

and u cant just put the script in there

lime ridge
#

wait

keen estuary
#

it has to be a gameobject thats containing that script

lime ridge
#

He is called OnButtonClick

keen estuary
#

yea but irregardless

#

this can't be that

lime ridge
#

Whuut

keen estuary
#

u just dropped the script in there

lime ridge
#

So where did i need to put it?

keen estuary
#

just put it on a gameobject somewhere in ur scene

#

something that makes sense

lime ridge
#

On the Wheel?

upper thicket
#

an empty game object (for the script to run)

#

it will be invisible. place it anywhere

lime ridge
#

already did it

#

can i change the name of gameobject too?

upper thicket
#

Hmm, there should be two arrays there

#

did you Save the script?

lime ridge
#

yes i save

upper thicket
#

Show the script

lime ridge
#

already got

upper thicket
#

ok good

lime ridge
upper thicket
#

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:

lime ridge
#

I put this

lime ridge
#

?

upper thicket
#

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.

lime ridge
#

WheelObjects

#

its same of WheelParent

#

everything is inside him

upper thicket
#

oh

#

hm, I can't recall if there's any need to disable the children

keen estuary
#

.. not sure what the end goal is here.. im just seeing pointing out errors i catch lol

lime ridge
#

Spawn

keen estuary
#

sup

upper thicket
#

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

lime ridge
#

the end goal is

#

when the user get the prize on the wheel 1

#

appear's a button "Go to second wheel"

keen estuary
#

mmhmm gotcha

lime ridge
#

If u see the vid

#

u understand

upper thicket
#

Oh, a second button

lime ridge
#

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..

keen estuary
#

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..

lime ridge
#

ok i will tell you

#

wait a sec pls bor

keen estuary
#

it looks like alot of it is working how it should.. so

lime ridge
#

bro*

keen estuary
#

u got most of it working.. i dont get how this is any different than that other stuff..

lime ridge
#

Here

#

this is the prize

#

50$ righ

keen estuary
#

aight.. yup, i seen that part

lime ridge
#

and this button

keen estuary
#

which button?

lime ridge
#

bring me back to the first wheel again

keen estuary
#

the bag of cash

#

is that the button?

lime ridge
keen estuary
#

ohh ok

lime ridge
#

is not a button

#

is a text that makes a button kkakkakk

keen estuary
#

so it is a button

lime ridge
#

yes it is

keen estuary
#

lol

upper thicket
#

clickable text ๐Ÿ•ต๏ธ

lime ridge
#

muahahah

#

and when i press him

keen estuary
#

ok.. so when u press that button

lime ridge
#

he brings me to the start again

keen estuary
#

ok.. and is that not what u want to happen?

lime ridge
#

and i want that he brings me to the second wheel

keen estuary
#

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?

lime ridge
#

yes

keen estuary
#

yea.. but do u call code to take u back to the start

lime ridge
#

because

#

the wheel one

#

when it ends the spin

#

makes this

keen estuary
#

^ this is the word button one?

lime ridge
#

yes

#

independently of the outcome

keen estuary
#

i dont see anything there that would take u back to the start

lime ridge
#

oh imsry

#

wait wait wait

keen estuary
#

unless ur ClaimReward() function does it

lime ridge
upper thicket
#

Where in the code is the action for when the text is clicked?

keen estuary
#

soo.. if thats why it happens why not change it so it doesnt happen?

lime ridge
#

No

#

Because

#

this "clickable text"

keen estuary
#

yea?

lime ridge
#

always appear independently

#

of the prize

#

or not prize u got?...

keen estuary
#

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

lime ridge
#

ok

keen estuary
#

i thought thats what this was all about...

lime ridge
#

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

keen estuary
#

yea, that shouldn't send u back to the start of the game?

#

i dont see anything there that would

lime ridge
#

Yes he send

#

cause of that wait

#

When i press the button

lime ridge
lime ridge
#

activate the Spin Button

keen estuary
#

when u press the button yea i see.. u set active all those objects

lime ridge
#

Exactly

#

And those objects

#

are from the Wheel 1

keen estuary
#

alrighty

#

soo... have 2 different buttons lol

#

the other button u can change out with WheelParent2

#

Wheelborder2

#

wheelarrow2

lime ridge
#

Yes i can

keen estuary
#

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

lime ridge
#

no bro

keen estuary
#

which then does the same thing as wheel1 button but instead uses all ur wheel2 objects

lime ridge
#

No bro..

#

This button always appear after the wheel 1 spins

keen estuary
#

idk if u explaining it again is gonna do good or worse tbh

keen estuary
#

or is that what u want to happen or what?

lime ridge
#

And i want to make this button just appear

#

when the prize was "not prize"

keen estuary
#

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

lime ridge
#

here are the item_types

#

prem = prize noprem = no prize

keen estuary
#

ya.. so just check the enum..

lime ridge
keen estuary
#

i mean, i dont even see the enum being used tbh

upper thicket
#

Sidenote: Both for-loops can use int i as long as they are not nested inside one another

keen estuary
#

^ pro move

#

lOl

#

im confuzed af ngl

lime ridge
#

u and me bro

#

im getting crazy with this 4 real kkkkkkkk

keen estuary
#

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 ๐Ÿ˜„

upper thicket
#

Alright. Have you made any changes to the code during this conversation? @lime ridge

keen estuary
#

Rov go beast mode

lime ridge
keen estuary
#

im missing something simple. cuz how could this be hard.. if u have an enum lol..

#

if enum == noprize { //enable the darn button}

upper thicket
# lime ridge nop

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

keen estuary
#

^ I see where u going with this

upper thicket
#

Use the example script from before (the one in the scene). Just rewrite it completely.

upper thicket
#

Once that is done, you will set the buttons to do those methods* in stead

keen estuary
#

this is better strategy anyway tbh

lime ridge
#

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#

lime ridge
#

??

keen estuary
#

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...

lime ridge
keen estuary
#

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);
    }```
lime ridge
#

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

keen estuary
#

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

lime ridge
#

Ye i know, but this seems to be an very easy thing and i cant to solve

#

...

keen estuary
#

it enables this and this and this

#

but now we could just call 1 function

lime ridge
#

Yeah ok i understand no

#

now*

#

I make a script with this

#

for 2 buttons?

upper thicket
#

a script with methods that buttons can use

lime ridge
#

everything on the same script

#

right?

upper thicket
#

yes, for simplicity

keen estuary
upper thicket
#

structure is nice. Your script is a bit of a challenge with its size ๐Ÿ˜…

keen estuary
#

see now my button actually does 1 singular thing

#

but it actually does all this junk

lime ridge
#

ye i understand

#

bro

keen estuary
#
    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

lime ridge
#

Ok

#

and i will put the enum

#

here too?

#

to enable the button 1 if enum = prize

#

or not?

upper thicket
#

Rephrase the last two things. (I can't understand xD, Maybe I'm just out of juice)

lime ridge
lime ridge
#

and after this how i will connect the enum to know if is to show button 1 or button 2?

upper thicket
#

Where is the code for where you would spawn button 2 ?

#

wait, it's not up yet

keen estuary
#
    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..

keen estuary
#

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;

lime ridge
#

But im using enum bro...

keen estuary
#

if u add something to the array set the bool to tru

#

u say u are..

upper thicket
#
if(rewardObject.CompareTag("Extra Spin Reward"))
{
    OpenWheel();
}
keen estuary
#

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

lime ridge
#

Well

#

i need to create a script with all the functions to the button first

upper thicket
#

Fix what can be fixed. Then get some rest. You already made all this. You'll figure out a way.

lime ridge
#

Bro i dont make anything

#

Literally i cant make anything

upper thicket
#

Have you not created this project by yourself?

lime ridge
#

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

keen estuary
#

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'

lime ridge
#

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

upper thicket
#

From where did you get it btw?

keen estuary
#

but i dont think u know the basics enuff and thats why ur hung up on this one part

upper thicket
#

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.

keen estuary
#

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

keen estuary
#

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

upper thicket
#

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.

keen estuary
#

^

#

ur just a eureka moment/ facepalm away

upper thicket
#

Sleep is literally necessary to learn this stuff.

keen estuary
#

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..

lime ridge
#

oh

keen estuary
#

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

lime ridge
#

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

keen estuary
#

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

lime ridge
#

I won't be able to fix this.. I thought it was something much easy to solve

keen estuary
#

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)

keen estuary
#

and that proves my point exactly..

lime ridge
#

Yes i know u got certain

#

but i dont got the minimum experience to make this

#

thats the problem..

upper thicket
#

Yeah, if you had, we'd be done long ago ๐Ÿ˜…

keen estuary
upper thicket
#

The solution is in here if you manage to piece it together.
Good luck, bro โœŠ

keen estuary
#

its alot easier to do this.. and call DoStuff(); in the button

#

than to instead have ur inspector look like this ^

upper thicket
#

This man makes games. Listen to his advice.

keen estuary
#

but yea, i must be getting to work speaking of..

#

like Rov said.. the solution is here..

lime ridge
#

Thats ok... im grateful for the help

keen estuary
#

all u need is a boolean.. and a gameObject.SetActive(true);

lime ridge
#

4 real

keen estuary
#

ull get it

#

๐Ÿ€ good luck mate

lime ridge
#

and made all that i got right now

keen estuary
#

ok, ๐Ÿ‘ i might look that over in my downtime