I currently have a problem in my custom character controller. I have code that moves a Gameobject's transform.postion.y to simulate gravity and ground is detected using SphereCast. SphereCast is thrown from the middle of the body towards the bottom. And then I have a big cube as my ground.
When I position the character very high above the cube and then press the Play button, the character drops and SphereCast detects a hit (scenario 1). But when I position it still high above the cube but not as high as the first example, the SphereCast doesn't detect a hit (scenario 2). So it only detects a hit when I start it really high. And this only happens on initial run, because I have a jump function and when I do the first scenario (hits ground) and then do a jump, the landing after the jump is detected by SphereCast even though the jump is same height as scenario 2.
So my next step is, adding a breakpoint in SphereCast hit while playing scenario 2 frame by frame. The thing is, when frame by frame, scenario 2 is detected by SphereCast, so I'm at a lost on how to debug this.
- SphereCast hits ground when character is placed really high above ground then hitting Play button (scenario 1)
- SphereCast doesn't hit ground when character is placed moderately high above ground then hitting Play button (scenario 2)
- If scenario 2 is done frame-by-frame, SphereCast hits
- Need ideas on how to debug