CIS-499-Group3 / Team3-Project

4 stars 2 forks source link

Ghost Collision #14

Closed huntrben closed 8 years ago

huntrben commented 8 years ago

I was curious if anyone else noticed that the ghost can pass through walls. I've been messing around with stuff, so I wanted to see if I broke it on my end or if the ghost could occasionally ignore walls. It doesn't do it all the time, though, so I'm not sure how serious it is.

SpenceSellers commented 8 years ago

This is absolutely a bug. We might have to fix it, but I suspect it's caused by how the current ghost test AI is implemented. It just chooses a random direction every single frame. I think so many changes so quickly ends up confusing Phaser's collision detection. It's likely the issue will disappear entirely with a real ghost AI.

SpenceSellers commented 8 years ago

I kind of fixed this maybe??? Out of curiosity I tried to see how the problem would change as I changed CENTER_TILE_EPSILON, which is how many pixels a Creature will still consider the 'center' of a tile. It used to be 5. Changing it to 10 seemed to get rid of the problem without affecting gameplay. If anything, turns are even more forgiving now.

I think the change might just be allowing the ghost more opportunities to change its mind about going through walls though, so ??

alan-boggess commented 8 years ago

Collision hasn't been set for Ghosts in the game.ts module. (Lines 83 and 84 set collision for player and the current layer and set the logging thereof, but no such lines set collision for ghost objects.) Consequently, ghosts are perfectly happy to move right through walls if their algorithm tells them to do so between the edge of the tile and the epsilon centering. (I think? Maybe it's between the epsilon and the center? Not sure.)

This might be a feature, not a bug, if we want an easy way to prevent the player from moving into the ghost-spawning region of the board - write the base ghost class to move themselves out of the box before beginning their sub-class behaviors and just write all the sub-class behaviors to do some sanity checking before they choose their new direction every time their algorithm requires them to do so. (The latter bit there is going to be necessary even if we implement ghost collision with the playing field, since otherwise it might pick a straight-line path that has it continuously trying to bump into a wall.)

SpenceSellers commented 8 years ago

Nice find! I forgot that ghost collision wouldn't be enabled. That explains why I was never able to replicate the bug with pacman. I spent a few minutes running him into corners and spamming all of the direction keys as fast as possible, but he never went through a wall :D

alan-boggess commented 8 years ago

So, the value of the epsilon does seem to affect gameplay for the new ghost behavior - the new ghost centers itself on basically every tile, even when it isn't changing direction, so larger values of the epsilon cause its movement to become more jittery and the ghost itself to move faster. I've changed the value back to 5 for now; that's small enough to make it stop stuttering, although it's still slightly faster than the player at that value. We might want to lower that value a hair if we decide to implement a "chaser" ghost.

kmcurtis915 commented 8 years ago

Hey just getting back in the country from a seven day cruise..couldn't afford the price of full access wifi on the ship so I've been out of touch with the project..I see everybody has been working..I just pulled the latest and greatest from the repository so I will see what all I can do to contribute