The Daily Click ::. Forums ::. Klik Coding Help ::. Moving around objects/bg (with vector movement?)
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
21st January, 2012 at 02:19:52 -

Sort of fixed, the way I described in the previous post:
https://skydrive.live.com/redir.aspx?cid=b1e7ee094271bbda&resid=B1E7EE094271BBDA!492&parid=B1E7EE094271BBDA!131

I'm starting to think this might not be the way forward though - it's going to be hard to stop units overlapping each other.
Maybe try moving them one at a time, in order of proximity to the destination, using ForEach loops?

 
n/a

SolarB



Registered
  26/12/2011
Points
  564
21st January, 2012 at 22:50:49 -

Here's my solution, yours is probably better but mine are spaced out more...

http://www.mediafire.com/?u5vbwplqt9aw7rt

Argh loops, well I had to do them anyway in my engine as I'm just using the base units as dummy objects (I need my actual units to keep their angle). Still weary of PF objects, my map is 6000x4000 so that might not be feasible just now

 
My Open Source Examples: http://bit.ly/YyUFUh

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
22nd January, 2012 at 00:18:54 -

There are a couple of issues with that:
* Units always turn to face East after moving.
* Even on a wide open map, the units stop a long way short of where you tell them to go.
* Sometimes units just become unresponsive, and you have to click three or four times to get them to move.

I hope by "dummy objects" you don't mean that they're invisible, and you have another object set to their position? That's not only incredibly inefficient, but it also makes the coding far more complicated than it needs to be.

Re: pathfinding extensions -
6000 x 4000 isn't huge. It just depends on the number of units and the level of precision you need. You could base your map on a 100 x 100 pixel grid, which would be a very manageable 60 x 40 squares - you'd use a pathfinding extension to navigate between squares (moving from the centre of one square to the centre of the next), and then when they reach the destination square, you give them precise destination coordinates within it.

 
n/a

SolarB



Registered
  26/12/2011
Points
  564
22nd January, 2012 at 02:30:59 -

Ok, since you say it's more efficient than the current option I may give pathfinding a go, but still not giving up on this quite yet.

What would be better than invisible dummies? I want directions instead of angles - units have separate direction animations. I'm going to try the 'convert angle to direction' option, hopefully it doesn't tamper with the collision detection...

 
My Open Source Examples: http://bit.ly/YyUFUh

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
22nd January, 2012 at 19:09:18 -

I'm not saying it would be more efficient - it would probably be slower. But, it would just work reliably, whatever the map design.
Instead of invisible dummies, just use the same object for both, but store current heading in an alterable value - then you can set the angle to that while checking for collisions, and back to 0 afterwards.

 
n/a

SolarB



Registered
  26/12/2011
Points
  564
24th January, 2012 at 13:30:59 -

Thanks, will try it.

 
My Open Source Examples: http://bit.ly/YyUFUh
   

Post Reply



 



Advertisement

Worth A Click