playMaker

Author Topic: Trying to make a game like The Fortune Wheel  (Read 1733 times)

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Trying to make a game like The Fortune Wheel
« on: November 04, 2018, 10:59:24 AM »
Hello everyone,

I'm trying to prototype a new game like the Fortune Wheel.
Currently I can spin the wheel physically and it stops with the friction. The wheel as a rigidbody and don't use the gravity and is not kinematic.
To find out where the arrow stops, I throw a raycast from the bottom of this arrow. This raycast records a hitobject placed on the wheel.
I am now looking for ideas especially for how to know when the wheel is stopped to know the good hitobject with the raycast (because the raycast records the hitobject as the wheel rotates)?

And after when the hitobject is found I want to show the gain.

I think I must ensure that the wheel stops completely when it is between two studs but I do not know how to go there.


daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Trying to make a game like The Fortune Wheel
« Reply #1 on: November 04, 2018, 10:25:35 PM »
Hello everyone,

I'm trying to prototype a new game like the Fortune Wheel.
Currently I can spin the wheel physically and it stops with the friction. The wheel as a rigidbody and don't use the gravity and is not kinematic.
To find out where the arrow stops, I throw a raycast from the bottom of this arrow. This raycast records a hitobject placed on the wheel.
I am now looking for ideas especially for how to know when the wheel is stopped to know the good hitobject with the raycast (because the raycast records the hitobject as the wheel rotates)?

And after when the hitobject is found I want to show the gain.

I think I must ensure that the wheel stops completely when it is between two studs but I do not know how to go there.

It sounds like you already did the hard part.

For checking for the wheel stop; you can literally directly check if the wheel is moving or not. Get's it's rotation as a vector. You take the rotation once to store as int X, then take it again a second later (or what ever quick timing) to store as int Y. You then compare int X to Y. If they are different, the wheel is obviously still moving, so you loop back and do this check sequence again. You want this sequence to only start after you know the wheel has been spun.

For the in-between part; Maybe try something like this. First do the above so you know the wheel stopped. Next, either do the ray cast thing again to see you are in between, or place actual triggers in those positions. Personally I would do the triggers (not to say that's better). With this, you can wait for the spin first, wait for the stop second, then activate the triggers (or other between ray system) and make it add just a tiny bit more rotation to the wheel if it returns true. So the trigger gameobject itself may go from inactive to active and then be the thing that has a Trigger Event so if you land on it then it spins the wheel a little more to get it off the spot.

For showing the gain; I'm actually surprised you rigged the rest up but are asking about this. Maybe I'm not getting your question. Are you asking the technical side of it like how you know what the gain is (identifying the actual part of the wheel)? Or how you make UI or other visual changes to show what you got? Or are you asking for some ideas of what would look good from a design point of view?

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Trying to make a game like The Fortune Wheel
« Reply #2 on: November 06, 2018, 12:59:46 PM »
Hi daniellogin,

thanks for your reply :)

I think you've put me on the right track.

I managed to stop the wheel when it's almost stopped.

This is how I did it:

- The button rotate it and send an event that compares the X position of one of the pads every half second. So I get X and X1

- Another FSM compares the 2 values ​​and when they are equal with 0.015 tolerence it sends to another event that puts the wheel in "isKinematic" so that it stops completely.

- From there I'm doing a raycast to find out exactly where the arrow is pointing.

It all seems to work very well.

Now the prototype of the spinning wheel is OK for me.

The next phase is to make a home menu that allows up to 8 players to enter their name. Once these names are entered we click on PLAY and it sends us to the scene of the wheel.

There, however, I do not see how to do all that.

An idea maybe? A tutorial?

I wish to make a local multiplayer on the same device.

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Trying to make a game like The Fortune Wheel
« Reply #3 on: November 06, 2018, 10:40:26 PM »
Sounds like you are doing a good job so far.

So as far as play names go; this may depend on how complicated/what exactly you want to do.

Is it just once off data? Like the players enter their name but the game forgets next time it opens? Or is it more complicated with saved profiles and saved high scores which persist between plays?

To keep data between plays you will need to look up how to save database like files. I think they even use XML and similar. It's the same kind of thing you use to make complicated game saves, although simple high scores and profiles would be much easier.

However for the most simple form, with once off names used for display only in one game, the first step is to consider the game logic of how the player(s) will choose how many are actually playing- so it doesn't ask for 8 names when only 4 people are playing.

Next (for the simply still) you will need to rig up something that watches for any key stroke and records it. The variable for text is called a "String" (keep that in mind for searching for tutorials).
I did a mega quick search for "Playmaker text variable" (because "String" evaded my mind at the time) and easily found results in Google. Here is one: https://www.youtube.com/watch?v=r2dJMp1QDRM

I didn't really watch it so don't know if it has everything you need, but it does seem to show you the starting point of how you can watch the key strokes and do something with them. Does seem to be one of those silent + wave the mouse cursor ones, but yeah, may be helpful anyway.

Once you have saved some inputs as String variables then you simply do a Set Property for Text Mesh Pro (free). You select the actual component itself (not the gameobject for it) and then select.. um... I forgot. Maybe just "text" or something like that. Scroll down a little, the option is fairly obvious when you see it. Use it to set the text to be what the String is. I saw somewhere on this forum someone actually made a custom action set for Playmaker and Text Mesh Pro, but the built in Set Property still works.
You may need to *lock the FSM* to do this, as when you click on the text's gameobject you will see it open a new (probably blank) FSM. There is a little lock button on the FSM window so it will stay on that FSM no matter what gameobject you click (allowing you to click another object and see it's components to drag into an action).

Maybe for simplicity sake have all 8 text objects positioned in your UI, but start them with no text (blank) and so can use the Strings to set them to something otherwise you wont' know they are even there.

And yeah, if you didn't already know, built in Unity text is garbage. Use Text Mesh Pro (free version) or something else or all you will get is jaggy terrible text.
« Last Edit: November 06, 2018, 10:47:14 PM by daniellogin »

Franck

  • Junior Playmaker
  • **
  • Posts: 91
Re: Trying to make a game like The Fortune Wheel
« Reply #4 on: November 07, 2018, 04:42:34 AM »
wow thank you very much for your kindness.

Indeed, it is not necessary to register the games. Player names should only appear for the game in progress.

I proceeded like this to put all this in place:

- UI Input Field Get Text
- Saving text in a global variable (because it's in the main menu)
- In the game scene, I get the previous global variable and I display the text typed by the players

Now the next step is to put a drop-down list that goes from 1 to 8 and display the correct number of Input Field to not clutter the screen.

I slowly discovered Playmaker for about 1 or 2 months and I'm not a developer so sorry if I ask silly questions sometimes :)

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Trying to make a game like The Fortune Wheel
« Reply #5 on: November 07, 2018, 09:23:47 AM »
No problem. You're doing good from the sounds of it.

I'm no expert and not really a developer either. I actually do this stuff as a hobby just to tinker with. But that's why I'm happy to try to lend a hand because it was me asking really basic and "silly" questions not long ago and I still come here for help from the real experts.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Trying to make a game like The Fortune Wheel
« Reply #6 on: November 07, 2018, 01:41:51 PM »
Hi.
4-5 years ago i was one of those who asked silly questions here ;)

That time there where a lot less custom actions around.
So i started to look to the scripts, to see how things worked and started to make my own action.
Meanwhile i started looking to the questions and tried to find solutions for the questions, which learned me a lot.

Now i am even comfortable programming in C# even outside unity.
And also earning as a freelancer and forum support
and i have all to thank to PlayMaker!