Jump to content


Photo

Moving Along a Path help


  • Please log in to reply
7 replies to this topic

#1 akaru7251

akaru7251

    GMC Member

  • New Member
  • 5 posts
  • Version:GM8

Posted 04 May 2012 - 05:01 PM

Hello,

I am working on a simple board game idea and am running into an issue of how to implement the movements. I want it so I set a path along the entire map (board) with a node on each space. I have a "roll" button that will randomly generate a number from 1-6. Based upon the number, I want the player/cpu to move that many nodes along the path. Is this possible or do I need to do this a different way?

Also, I figure once it gets close to the end of the path (loop back to start) I will have a simple check:

moveTo = rndNum + currentNode;
if ( moveTo >= totalNodes)
{
moveTo = moveTo - totalNodes;
}

Or will the path just loop itself if I have it closed?

Thanks
  • 0

#2 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1464 posts
  • Version:GM8.1

Posted 04 May 2012 - 05:30 PM

try setting an alarm when you click to a certain number and set path_speed to 4 or something like that
in the alarm event you reset it to 0 again
and initialize the path with speed 0 in the create event and select to restart when it is done.
  • 0

#3 ondesic

ondesic

    GMC Member

  • New Member
  • 36 posts
  • Version:Unknown

Posted 21 May 2012 - 06:52 PM

try setting an alarm when you click to a certain number and set path_speed to 4 or something like that
in the alarm event you reset it to 0 again
and initialize the path with speed 0 in the create event and select to restart when it is done.


This topic is exactly what I need. Are the nodes to a path saved in memory? It would be awesome to have built in functionality where you simply can advance a object to the next node or previous node, or any node with simple code. Is this posible now?
  • 0

#4 ondesic

ondesic

    GMC Member

  • New Member
  • 36 posts
  • Version:Unknown

Posted 23 May 2012 - 02:27 AM


try setting an alarm when you click to a certain number and set path_speed to 4 or something like that
in the alarm event you reset it to 0 again
and initialize the path with speed 0 in the create event and select to restart when it is done.


This topic is exactly what I need. Are the nodes to a path saved in memory? It would be awesome to have built in functionality where you simply can advance a object to the next node or previous node, or any node with simple code. Is this posible now?


Does anyone know if this is possible?
  • 0

#5 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1464 posts
  • Version:GM8.1

Posted 23 May 2012 - 10:55 AM

Do you mean teleporting to the next node or moving to the next node?
  • 0

#6 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5383 posts
  • Version:GM:Studio

Posted 23 May 2012 - 11:19 AM

@ondesic:
path_get_point_x(ind,n)
path_get_point_y(ind,n)
if you place a node on each, then you should be able to return the cordinates with those .. as for the code, you could move to the next with mp_linear_step or any other of those, when there you increase your current position, and check if this is the target position, if not then target the next node..

@akaru7251: atm it looks like your code jumps directly to the node you will end at, instead of increasing it with 1, moving there and reapeating that untill it have moved its steps.. if you want to move it back to the first then just check if it is on the last one becore increasing it .. if so then place it on the first and don't increase it.

A board editor project I got:mario_party_array_v0_5.gmk
(GM 8.0 pro)

Edited by FoxInABox, 23 May 2012 - 11:28 AM.

  • 0

#7 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 340 posts
  • Version:GM8.1

Posted 23 May 2012 - 05:34 PM

@ondesic:

path_get_point_x(ind,n)
path_get_point_y(ind,n)
if you place a node on each, then you should be able to return the cordinates with those .. as for the code, you could move to the next with mp_linear_step or any other of those, when there you increase your current position, and check if this is the target position, if not then target the next node..

@akaru7251: atm it looks like your code jumps directly to the node you will end at, instead of increasing it with 1, moving there and reapeating that untill it have moved its steps.. if you want to move it back to the first then just check if it is on the last one becore increasing it .. if so then place it on the first and don't increase it.

A board editor project I got:mario_party_array_v0_5.gmk
(GM 8.0 pro)

How about this, make the path go around the entire board and set it to restart at the end and set the path speed to 0. In the player object, put in the create event: spaces_to_be_moved and set that var to 0. When you roll, add that number to the var and set the path speed to whatever. Then in a collision event for the node have it set player.spaces_to_be_moved to -1 and check the relative box. Then in your step event for your player, check var if spaces_to_be_moved = 0 (perform next action) Path speed = 0.
  • 0

#8 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 340 posts
  • Version:GM8.1

Posted 23 May 2012 - 06:17 PM


@ondesic:

path_get_point_x(ind,n)
path_get_point_y(ind,n)
if you place a node on each, then you should be able to return the cordinates with those .. as for the code, you could move to the next with mp_linear_step or any other of those, when there you increase your current position, and check if this is the target position, if not then target the next node..

@akaru7251: atm it looks like your code jumps directly to the node you will end at, instead of increasing it with 1, moving there and reapeating that untill it have moved its steps.. if you want to move it back to the first then just check if it is on the last one becore increasing it .. if so then place it on the first and don't increase it.

A board editor project I got:mario_party_array_v0_5.gmk
(GM 8.0 pro)

How about this, make the path go around the entire board and set it to restart at the end and set the path speed to 0. In the player object, put in the create event: spaces_to_be_moved and set that var to 0. When you roll, add that number to the var and set the path speed to whatever. Then in a collision event for the node have it set player.spaces_to_be_moved to -1 and check the relative box. Then in your step event for your player, check var if spaces_to_be_moved = 0 (perform next action) Path speed = 0.

Did I solve your problem?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users