Simple rts question->waypoints

For questions about using Classic.

Post » Mon Dec 01, 2008 4:37 am

So what exactly is a waypoint, besides the obvious x,y position?
I mean does it do anything else besides offer a container for a position variable?
From what I can tell, it looks like it has some pathfinding involved. Example I had a group of tanks set to move to the waypoint when I clicked a position, most of them instead of moving directly to that position, chose a path up, and around another "solid" object, that wasn't any way near either. Notice I said most of them, a few just ran into each other and stopped. I gather they couldn't figure a decent path is probably why they stopped.

Then I have another question somewhat related.
When you add the rts behavior, with the avoid other object event, is there any way to keep them from "fighting" for position?
Now I realize this is always going to happen in a confined area along a path, but what about when they get to point x,y? They can't all occupy the same space.

Basically whats needed is a way to give each object its own private variable, even if they are the same object. Then assign them that private variable= destination x,y + (random*n+ whatever the sprite size is), n being how many of the same objects there are, then roll the dice again if the x,y is the same.

I don't know if that would solve the waypoint problem, but it should for the second question.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Mon Dec 01, 2008 6:52 pm

A waypoint is just a location to move to. If you say 'Move to X, Y' and enter a coordinate the other side of the map, obviously the unit tries to reach that coordinate. If you say 'Add waypoint at <position other side of map>, Add waypoint at <original position>' then the unit goes to both waypoints, in order. It'll go to the other side of the map, then come back to its original position.

As for units moving over each other - use 'Avoid moving over object' action on start of layout. The RTS basics template has an example of this. Units will negotiate in to a queue and not overlap too much.

It's not perfect though and I've been planning on improving it, especially since it's annoyingly easy to set up parameters that make them spin around in a dumb way, and you have to tweak the parameters at the moment to get it to work right. Hopefully I can come up with a better engine. It's really tricky stuff though.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Mon Dec 01, 2008 9:39 pm

[quote:1wq07n7q]annoyingly easy [/quote:1wq07n7q]
Yeah it is. heh I spent a few hours on it and finally got some decent results by un-checking "solid", setting the "blocked speed" to 0, and setting the cell size to approximately 2x the sprites size.
That's using the bounding box for collisions. You still get the occasional overlapping, but if you add an action like "if object is overlapping" move to some somewhere else. That's still a little spurious as they are all the same object.

I was thinking it might be possible to use the family attribute to set up some kind of loop that gets the unique id for each member of the family, and then when a group is told to go to x,y points, instead of all going to one spot, they are each given a different coordinate that does not over lap.
Sort of like go to waypoint, but go to area instead. Thing is the loop would have to be done at start up, and then again if a object in the family is spawned, or destroyed. Im just not sure how to set up a variable like that.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 13 guests