|
Hi folks, i'm relatively new to programming and even more so with Unity. What i'm trying to do is create Pac-man for a University Coursework. I have quite a lot of it working, however a new problem has arisen and I don't know why. Pac-man used to have a rigidbody attached to handle the collisions, however due to the forces applied (I think?) he kept bouncing off the maze walls. On further research I found the Character Controllers do not take forces into account. All was working well until I realised that more often than not double the score was given for each pellet consumed (sometimes the correct score was given). This only happened after I changed to Character Controller. I've checked the log and it is incrementing by 100 but incrementing twice per collision. Any help is greatly appreciated. Here's my Consume code:
(comments are locked)
|
|
Just disable the pellet collider when you eat it, boom no more collisions and it will eventually get destroyed. I don't have Unity if front of me, but it should be something along the lines of gameObject.Collider.Active = false Or...just disabling the whole pellet might do the trick also.
(comments are locked)
|
|
Try DestroyImmediate instead of Destroy - it could be that your other object is hanging around for two fixedupdates before being deleted (which is feasible - you get 0 to lots of fixed updates every frame, depending on the timing) Edit, since that failed spectacularly:
that should just move the other object far away from the play zone so it can't be collided with twice Thanks but i've tried DestroyImmediate and Unity crashes =/ Is there any other way to do this? I also tried "yield" before the Destroy and no luck
Jul 14 '10 at 12:02 AM
Peange
(comments are locked)
|
|
Instead of using I have the same issue but unfortnately what you said Karl still has the double hit problem ? here is my code snippet ,any ideas ? etc sometimes ,randomly it moves the cube objects down twice 2000 instead of 1000 ?
Mar 03 at 12:26 PM
javanoob
(comments are locked)
|
