Click to Move + WASD = general bad behaviour plus bonus issues!

So I have run into a number of issues that I can’t seem to debug. (Unity 5.6.0f3 + VS2017) They all seem to come to a head in Click to move hence the reason I am putting this here.

Issue #1 - All my print(yadda.yadda); lines continuously print out in Update and FixedUpdate. In Update the print(cameraRaycaster.layerHit); in cursor.cs scrolls to infinity as soon as I hit play. The walkable print statement prints to the console as Ethan walks around. I have gone through the lecture a couple times and can’t seem to figure out what I have done differently. It looks like each should print out once not either infinite amount of times or repetitively during animation. (eg. I click the ground 5m away from Ethan and the console logs the walkable print statement over and over until Ethan gets to his destination)

Issue # 2 - My Enemies are on layer Enemy yet when I click on them the camera / cursor sees right through them and clicks the ground behind them. This is true for blocks with layer Enemy and multiple Ethan’s on same said layer. The other thing is the console never logs the text in the print statement for enemy so it is like they are invisible. Ethan will walk through the enemies but not through blocks on the Enemy layer. He stops but his animation keeps going as we

Issue #3 - distanceToBackground is set yet Ethan runs right off the edge of the earth. It’s quite amusing as he decends into infinite darkness but not quite the functionality I want. I set the ground size to 210,1,210 so it is more than 100m in any direction from the center. However with the parameter set at 100 he still leaps to his death. As above the console doesn’t log the default print statement but then again Ethan never seems to hit that invisible wall so I guess…that makes sense?

Main Issue - If I click on the ground and then want Ethan to move via WASD he does this awesome little dance with his feet. (Much like the moves I had in the clubs back in the 80’s) If I wait for him to stop, WASD works but Ethan turns into the Flash on like 20 red bulls and screams away so fast the camera can’t catch up. Why is his speed and animation so drastically different with WASD than with click to move? I have played with all the attributes under Third Person Character and that doesn’t solve the problem. So how can I use both click to move and WASD at the same time? Also how do I adjust his move speed with WASD? When I change the parameters it does affect the click to move speed and animation but not WASD.

For Issue #1, It is normal behavior to print every frame. What Ben did in the videos was click the “Collapse” button at the top of the console panel so that instead of seeing the same message over and over, you’d see it once, with a number to the right that increments.

Issue #2: I had that problem and in my case, it was a missing collider component. That would make them “invisible” to raytracing, which uses the colliders.

Issue #3: I don’t think distanceToBackground will prevent falling off the world; need to build a world with a rim to prevent that. distanceToBackground just limits the ray tracing for performance reasons, I think.

Main: I also see different behavior from the slides but different from yours too. I’m using Unity 2017 beta, and it might be an issue of the version of not only unity, but the version of the 3rd person character being used. Or it could be related to which “update” runs first in which script. If you need WASD and click-to-move at the same time, you’d probably need to rewrite the code for the player movement script a bit; mainly, to make sure the movement function is not called when ethan is at his destination, so that WASD doesn’t conflict with it. It’s a case of two scripts controlling the character at the same time, so that means the behavior is “undefined” anyway.

1 Like

So good news is a couple of the issues are fixed in later video’s! I figured out the collapse option a couple days after I posted this as well as the collider. Sadly, my enemies are still ghost like in the sense that the player can walk right through them. Have to work on figuring that out…

As for the background, you are correct kind of. With a mouse click it won’t let you walk off the end of the earth but WASD drives Ethan off the edge like a lemming as does the gamepad. That is something I need to work on as well.

Thanks for getting back to me though!

Privacy & Terms