playMaker

Author Topic: Monopoly Movement  (Read 3009 times)

Wayne191

  • Playmaker Newbie
  • *
  • Posts: 28
Monopoly Movement
« on: April 19, 2017, 12:33:46 AM »
Hi,

I am trying to create a movement system that is basically the same as Monopoly.

I created a route using several game objects (each game object represent one piece of land) and 2 game players (two game objects).

The followings are what I am trying to do:

1. Player A roll a dice (1~6) and use dice number for his movement.

2. Player B's turn: do the same thing.

3. back to Player A's turn.

What actions should I use to achieve these goals.

Can anyone help please?



jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Monopoly Movement
« Reply #1 on: April 19, 2017, 02:30:30 AM »
Hi,

 You will be able to achieve this in may different ways, I'll list two in order of complexity easy one first, more complex/powerful second.

-- use the action movetowards, target each route slots in turn so that your player stays on the route, then everytime movetowards action is finished check if the final target is reached, if yes, you can send a global event "Player move done" else move towards the next target

-- use itween or other tweening/path engine that have pathes and lets your animation gameobject along very complex splines, then you can also have taregt points and you simply use the path or tweening engine to animated it.

I would try the first solution first as for monopoly, I think it's enough.

 Bye,

 Jean

Wayne191

  • Playmaker Newbie
  • *
  • Posts: 28
Re: Monopoly Movement
« Reply #2 on: April 19, 2017, 06:22:29 AM »
Hi,

Say the player starts at position (x,y,z) (vector3) and dice rolled with a random number (integer). How can I connect these two different variables together so that the player can move according to his current position and move to the new position?

Below are my steps and I am not sure which steps are wrong:

1. Use ArrayList Proxy to set all lands' position in vector3.

2. Use ArrayList Index of to get the player's current position in variable integer. I did a quick test and it doesn't seem like the player's position is able to connect to ArrayList?

3. Use Random Int to get a random number between 1~6 and use Int Add to add two integers together (Random int + Player's position's int). (I am also stuck here because I cannot store the result of new integer. How can I tell the computer where to move to?)

4. I am thinking to use the new position's integer variable to get the new position's
vector3 and then use iTweenMoveTo or other methods to move to the new position.

Or maybe I am wrong from the 1st step?

Thank you for your help!



« Last Edit: April 19, 2017, 06:25:09 AM by walecowbe »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Monopoly Movement
« Reply #3 on: April 20, 2017, 01:57:41 AM »
Hi,

 you don't even need ArrayMaker, a simple FsmArray will do.

 have an FsmArray with as many items as there are slots on the board, drop on each the gameobject dummy that represents the position of each slots.

 then index 0 is the first slot, and you maintain an Fsm Int that represent the current index of the player, and one that is the targeted index where it is supposed to go and you will increment and move from slots to slot like that.

to reply to your questions:

1: no, you can use ArrayMaker, but PlayMaker also has a way to give you list.

2: it should, but I guess you are getting mixed up with the indexing and the content inside the item at that index.

4: don't use itween to move several slots because it will miss the turns and go straight across the board, unless this is what you want...


 Bye,

 Jean

Wayne191

  • Playmaker Newbie
  • *
  • Posts: 28
Re: Monopoly Movement
« Reply #4 on: April 20, 2017, 05:58:36 AM »
Hi Jean,

Thanks for your reply.

Do you mean add an array variable with gameobjects represent all the slots?

How can I relate these slot's position to the Player's position since the slot's position are just gameobjects and Player is not in the array ? Should I use GetPosition or ArrayGet?

I am new to Playmaker. Can you explain a little more in detail?

Wayne191

  • Playmaker Newbie
  • *
  • Posts: 28
Re: Monopoly Movement
« Reply #5 on: April 20, 2017, 08:02:23 AM »
I made it to move now. There are two things I am still trying to figure out if I can get some helps please.

1. It seems like the player is moving to a vector3 with floating point instead of integer for some reason. I set the start postion to be ( 0,0,0) and all the array vector3 are set in integer, but the player is not stopped at an interger vector3 location.

2. How can I make the player to follow the route I created while moving? I use MoveTowards and it doesn't follow the route.

Attached is a screenshot of what I am working on. Thanks.
« Last Edit: April 20, 2017, 08:17:14 AM by walecowbe »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Monopoly Movement
« Reply #6 on: April 20, 2017, 10:39:47 AM »
Hi,
A vectors are always a float value, even if you input a value of (for example) 1 it will still be handled as a float.

Your problem might be that your object is hitting other objects, try disabling the colliders or set them as trigger.

Wayne191

  • Playmaker Newbie
  • *
  • Posts: 28
Re: Monopoly Movement
« Reply #7 on: April 20, 2017, 11:22:00 AM »
Hi,

Thanks for your quick reply.

I just turned off all the box collider and it didn't work.
All the game objects I have are 16 cubes for the route and one cube for the player.

It seems like the player object is being push forward with a slight force.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Monopoly Movement
« Reply #8 on: April 20, 2017, 12:34:17 PM »
Hi,
Can you show the move state?

Wayne191

  • Playmaker Newbie
  • *
  • Posts: 28
Re: Monopoly Movement
« Reply #9 on: April 20, 2017, 09:06:03 PM »
Hi,

I attached the move state here. Thank you.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Monopoly Movement
« Reply #10 on: April 21, 2017, 02:52:52 AM »
Hi,
Your issue might be the 'Finish Distance'
on the "move towards" action.
The action will finish on 1 before the 'target position'

Wayne191

  • Playmaker Newbie
  • *
  • Posts: 28
Re: Monopoly Movement
« Reply #11 on: April 21, 2017, 06:54:40 AM »
Hi,

It works. Thanks for the help.

I am trying to find a way to switch turns between two players. I simply duplicate the player1 and rename it player2, but I cannot find anything in the action to switch between the 2 players FSM and let them move by turns.

How can I achieve this?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Monopoly Movement
« Reply #12 on: April 21, 2017, 07:18:31 AM »
Hi,
that depends on how you set up your project,
You can use for example a bool switch or if you have more than 2 player you can use an int switch.

lets say you start with player 1, when that player is done set a int variable (for example 'current player') to "2" then loop back to the int switch, it will detect 2 and will go to the state for player 2


Another possibility is to use arrays, use the int variable for the index nr, but player one should be 0, player 2 should be 1 and so on (arrays start @ index 0)

(for example) have one array for you 'player' gameobject and one for current positions, one for certain buffs or debufs, and so on...

A big advantage by using arrays is that you need a lot less states to do things.

if you would need 4 states per player...in the 1st method you will need 17 states

in the 2nds method 4 or 5.

There are some tutorials for arrays on the user tutorial wiki page