playMaker

Author Topic: Raycast vs. physics based character controller  (Read 920 times)

DennisJensen

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Raycast vs. physics based character controller
« on: May 09, 2017, 03:27:22 AM »
Hi Guys,

So I guess it's not a question regarding playmaker but Unity in general.

We been working on our game SIEGE! and we have had some problems with our physics based controller. I noticed I can turn the quality up or down, but I have also been experimenting with Ray casting to control when the character is hitting the ground or a wall.

Our problem is that sometimes the character goes through the floor or a wall. I would like to use ray casting because it seems like you have more control and it gives a better result. However the character still falls through the ground or through a wall.

Is it better to use physics? and is there a way I can turn the quality of the ray casting up? It seems a bit unstable as well. I need a big treshold to ensure the character doesn't go through the ground.
Game Designer, CEO, Artist
http://2ndStudio.com

DennisJensen

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Raycast vs. physics based character controller
« Reply #1 on: May 10, 2017, 12:22:27 AM »
I worked on the issue yesterday, and I found kinda a solution.

When I'm using raycasts for ground dectection, I had the problem of the character often fallen through the ground. The issue was that it wasn't being detected, I had a distance of 0.2 which meant that in almost half the cases it didn't hit the floor with a ray, and just went through it instead. So I increased the ray casts to have a distance of 0.4 which helps, but apparently it detects the floor at different distances, so sometimes my character would be half through the floor or with hes knees into the ground. Which looked bad. So I had to do a quick fix where I offset the character as he lands, I can output a hit distance from the raycast action and then subtract that from my ray distance which gives me the offset I need. Btw I run over 60 fps so it shouldn't be a performance issue.

But I'm still wondering if there is a way to get more solid ray casting, if I turn up quality of physics would that matter?
Game Designer, CEO, Artist
http://2ndStudio.com