HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Straight Line Movement

08-10-2005, 07:10 PM#1
Tim.
Alright I need to figure out a way of making the Ghosts in my Pacman map work thier way around the board. Attached is a recent screenshot.

I cant seem to get a working system to make the Ghosts move in straight lines until they hit a wall. On top of that, if they are within 1000 of Pacman they need to move in straight lines towards Pacman.

I tried placing units in every corner and having the Ghosts move to a random unit, but that looks really bad and not fluent.

08-10-2005, 07:41 PM#2
Vexorian
That's so cool.

But my only advice is to use a periodic trigger or timer for the movement of ghosts, pacman and cherry, the native pathing system won't help you here.
08-10-2005, 09:15 PM#3
Tim.
Yeah, thats what I use for Pacman, a periodic movement. The issue is I cant think of how to stop Pacman/Ghosts when they face a wall.

EDIT: I forgot to mention, the 'walls' where the lines are located are just pathing blockers. If that helps at all. (The terrain is totally flat, sence your at birds eye however one might have thought the blue lines were cliffs.)
08-12-2005, 07:40 AM#4
Oblivion9
Nevermind... sorry I didn't read your edit... i thought pathing blockers might help... but u already have them

Do you want them to move randomly?
08-12-2005, 12:22 PM#5
Tim.
The issue isnt getting them to move, its getting them to know when to turn. I can easily make a trigger randomly choose a direction at each turn, but I have yet to find a way to discover when a Ghost is at a turn. (Regions will not work, too complex and unreliable)
08-12-2005, 12:57 PM#6
Skwee
Put a dummy unit in the corner and set when a ghost comes within range?
08-12-2005, 03:57 PM#7
Tim.
Thats what I have been using up until now, however its not very effective. I would prefer a different meathod.
08-12-2005, 05:08 PM#8
Joey.
Well, since rects dont work... if you have pathing blockers, then the ghosts pathing should allow them to turn - after ording them to move to another area on the map, even while using only pathing blockers.
But im not sure, would it work any differently if it were done with cliff models?. (as in the earlier versions.)
08-12-2005, 11:01 PM#9
Vexorian
This remembers me my rolling boulder spell somehow, but in this case you could be using rects instead of cliffs, but if you use pathing blockers or cliffs there, you can check if the point is unpathable with the IsTerrainPathable native or by checking just after the moment you move them, if they are at the exact point you moved them, the place is pathable
08-13-2005, 02:24 AM#10
ElvinArcher123
Ehh... if they patrol... wouldnt they automatically follow pacman? couldnt you just Queue a patrol with pathing blockers?

If you could set it up like that it would work... unless i totally missed the question in that case feel free to flame me

EDIT:forgot to comment on how awesome that screenshot is =D keep it up!
08-13-2005, 08:04 PM#11
Tim.
Vex: Great idea!

Here is what I tried, however it doesnt work. Attached is a screenshots of the terrain without the texture.

Quote:
Move
Events
Time - Every 0.05 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Terrain type at ((Position of Pacman) offset by 25.00 towards (Facing of Pacman) degrees)) Equal to Ashenvale - Grass
Then - Actions
Unit - Move Pacman instantly to ((Position of Pacman) offset by 25.00 towards (Facing of Pacman) degrees)
Else - Actions
Game - Display to (All players) the text: STOP!



ElvinArcher123: Patrol would move them, yes, but they would move extremely predictably. Straight lines to pacman around the pathing blockers; On top of that they would turn around before hitting a wall if pacman went past them. Whereas in Pacman they are a little more random than that, depending on how far away from Pacman they are, the more accurate to him they are and only turn at corners.

EDIT: I found out some part fo the issue, if I incrase the value in the Condition from 25 to around 65 it works a lot more often, but not in all locations. If I incrase it to 100 it always seems to work, except then pacman is too far from the wall hes facing. I thought perhaps it was the direction pacman was facing, but it seems to be random. So then I thought maybe it had to deal with terrain variations; so I made all the variations identical. Variation 01 - Grass and Variation 01 -Rock. However, again, no change.
08-14-2005, 01:18 AM#12
drdlord
The way I'd do it is place a region at all intersections, create 2 arrays, in the first assign the regions, in the second assign each region's neighbors into the array.

IE:

locationArray[0] = top left corner
locationArray[1] = top left side, middle top
locationArray[2] = top left side, right corner
locationArray[3] = top right side, left corner
locationArray[4] = top right side, midle top
locationArray[5] = top right corner
locationArray[6] = top left side, left side of middle

array[0] = -1
array[1] = 1
array[2] = 6
array[3] = -1
array[4] = -1
array[5] = 2
array[6] = 7
array[7] = 0

and move it like this:

event:
-unit enters location1
-unit enters location2
-etc
contidion:
-entering unit = ghost
actions:
-destination = -1
-while (destination is -1)
-dir = random int from 1 to 4
-if (dir equals 1)
-destiniation = array[locationNumber*4]
-else if (dir equals 2)
-destiniation = array[(locationNumber*4)+1]
-else if (dir equals 3)
-destiniation = array[(locationNumber*4)+1]
-else if (dir equals 4)
-destiniation = array[(locationNumber*4)+1]
-move triggering unit to locationArray[dir]

course I'm not fixing memory leaks as I'm not sure enough that I'd catch em all but you get the idea, would take a while to set this up but should work well, test it with a small area.
08-14-2005, 01:39 AM#13
Tim.
Thats peachy, but it doesnt solve the problem, A) That would require a ton of Arays for all 12 players, and a ton of regions. B) What if the Ghost is simply passing the intersection and not running into it? You would have to check for the Ghost's facing angle to see if its facing the right way etc. a lot more complex than Vex's suggestion or my attempt above.

Anyway, I got somthing else now, if I make the collision size 0.01 instead of 50, it works at all walls with an offset value of 60. So aparently this has to do with how far from the walls the Ghosts are due to the Collision Size. How can we fix that so it works with a collision size of 50?
08-14-2005, 02:27 AM#14
drdlord
A) It wouldn't require a ton of arrays it would require 2, all the players can use the same array unless they each have their own board in which case you'd need a locationArray for each board but they could share the nebours array.

B) It's been a while since I played pacman, they never turn when going past an intersection? that would require a bunch of facing checks... still posible with my code but would be ugly....


I know my code here isn't the best way of doing it as it takes ALOT to setup; however it should WORK and all the other systems described so far have bugs.

Should probably keep trying to find a better system but I thought it was worth mentioning this one as it is somthing to do if all else fails. I've used this system in tower war maps and it worked fine
08-14-2005, 08:44 AM#15
Tim.
Everyone uses thier own playing field. Hense 2 arrays x 12 players = 24 arrays, each array has to be set 6 times. Besides, I tried with regions, and like I said, its unreliable. (Infact using hidden units with the 'Unit in 50 of unit GhostPoint[IntegerA]' would work better than regions.

Quote:
Anyway, I got somthing else now, if I make the collision size 0.01 instead of 50, it works at all walls with an offset value of 60. So aparently this has to do with how far from the walls the Ghosts are due to the Collision Size. How can we fix that so it works with a collision size of 50?