Monopoly Movement with Pathfinding?

Just started using Construct 2? Post your questions here

Post » Mon Jan 11, 2016 7:18 pm

heya, frist of check this out:

Image

I just had in mind to create a simple Monopoly movement, hopefully you understand what im trying to say :roll:

so here are my questions:
- is it possible to set the pathfinding to only in one direction? so that the object/player only walks forward means he has to go a full round to reach a certain point?
- next one, along this path i just mentioned earlier do im able to set something like a "checkpoint" ? since the route the player is moving on is always the same and doesnt change at all ? my intention was to create a function which just looks something like this moveto(nextcheckpoint.x, nextcheckpoint.y)
that means he checks which one is the nearst checkpoint and moves to it, and the normal movement method should look something like this moveto(Array.At(X),Array.At(Y))


i mean i could do it with couple if-statements but hopefully there is a easier way with the pathfinding method
B
5
S
1
Posts: 19
Reputation: 413

Post » Tue Jan 12, 2016 10:09 pm

You could do it just as you describe without the pathfinder.

Give the player sprite two variables: currentTarget=0 and goalTarget=0
Then give the square sprite one variable: targetId and number each instance, starting with 0, in the direction the board goes.

So the setup would be the player is placed on square 0. Then your events would look like this to move the player 5 spaces for example.

On start of layout
--- player: add 5 to goalTarget

player: currentTarget < self.goalTarget
square: targetId = player.currentTarget+1
--- player: set angle toward position (square.x, square.y)
--- player: move forward 100*dt pixels

player: is overlapping square
player: currentTarget < self.goalTarget
square: targetId = player.currentTarget+1
--- player: add 1 to currentTarget



I didn't take into account wrapping around the board or centering on the square but it's got the general idea.
B
94
S
33
G
113
Posts: 5,353
Reputation: 73,267

Post » Wed Jan 13, 2016 8:59 am

R0J0hound wrote:You could do it just as you describe without the pathfinder.

Give the player sprite two variables: currentTarget=0 and goalTarget=0
Then give the square sprite one variable: targetId and number each instance, starting with 0, in the direction the board goes.

So the setup would be the player is placed on square 0. Then your events would look like this to move the player 5 spaces for example.

On start of layout
--- player: add 5 to goalTarget

player: currentTarget < self.goalTarget
square: targetId = player.currentTarget+1
--- player: set angle toward position (square.x, square.y)
--- player: move forward 100*dt pixels

player: is overlapping square
player: currentTarget < self.goalTarget
square: targetId = player.currentTarget+1
--- player: add 1 to currentTarget



I didn't take into account wrapping around the board or centering on the square but it's got the general idea.


thank you for your answer! the basic idea it is working so far :lol:

ht tp:// www114.zippyshare.com/v/i9L3657R/file.html

but there are a couple problems,
- in this example i could change the goaltarget to 4 instead of 5 and it would be the same result why?
- also, my idea was to let the player walk forward until he reaches the end of one "line" and than he shouldnt just set a angle towards he is supposed to rotate by 90° and than keep on working to the goaltarget
- another point is, the player is not walking exact, normally he should walk to the origin point of the sqaure means the center

i hope you can help me out once more :|


greets
B
5
S
1
Posts: 19
Reputation: 413

Post » Wed Jan 13, 2016 9:10 am

If you like this demo, you might try this 3rd party behavior.
B
109
S
27
G
276
Posts: 4,479
Reputation: 154,418

Post » Fri Jan 15, 2016 8:50 pm

hey, thank you for your answer... it is working for me with your plugin, but to be honest i dont know what each of this functions do.. dont get me wrong normally i dont use plugins nothing against you, its just harder to understand for me

maybe there is an way without them :x

or would you translate thos functions into code that would be helpful too :o
B
5
S
1
Posts: 19
Reputation: 413


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests