playMaker

Author Topic: Player goes through the floor  (Read 2021 times)

DennisJensen

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Player goes through the floor
« on: July 29, 2017, 04:39:28 AM »
Hi Guys,

We are making our game KnightOut, and a fustrating bug I been dealing with is that the player can go through the floor causing the player to disappear and not respawn, which means it's game breaking.

I'm using raycasting for the player control. Which works really well.

The bug comes when the game is struggling with preformance. I think it has something to do with the quality of the physics. It doesn't happen if the computer runs the game smoothly.

We played our game live and the bug came, you can see it in this video, it also shows how the game plays out. When a lot of cannons ball are in the scene it gets laggy, maybe that's also something I should improve.


I'm a little bit lost here, any suggestions will help a lot.

Cheers
/Dennis

Edit:
Btw. I know it's not a playmaker problem but rather a Unity problem.
Game Designer, CEO, Artist
http://2ndStudio.com

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 747
    • View Profile
Re: Player goes through the floor
« Reply #1 on: July 29, 2017, 05:35:34 AM »
Have you tried changing the rigidbody collision detection settings? You can see it on the inspector. Dynamic/discrete/continuous.

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 747
    • View Profile
Re: Player goes through the floor
« Reply #2 on: July 29, 2017, 05:37:30 AM »
If that is not the issue, there appears to be a script here using raycast that might solve the issue: http://wiki.unity3d.com/index.php?title=DontGoThroughThings

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 747
    • View Profile
Re: Player goes through the floor
« Reply #3 on: July 29, 2017, 05:40:38 AM »
Last bump here, try.

Go to "Edit > Project Settings > Time" and reduce the 'Fixed Timestep'

Change it to a smaller value, like 0.01. It will cost a bit in performance but should keep objects from passing through each other under fast speeds, if simply changing the collision detection to continuous dynamic (which should be the first thing to try) didnt work.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4948
    • View Profile
    • jinxtergames
Re: Player goes through the floor
« Reply #4 on: July 29, 2017, 12:26:10 PM »
HI,
Quote
We played our game live and the bug came, you can see it in this video, it also shows how the game plays out. When a lot of cannons ball are in the scene it gets laggy, maybe that's also something I should improve.

Are you using 'create object' or are you using Object Pooling?

DennisJensen

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Player goes through the floor
« Reply #5 on: July 29, 2017, 12:58:45 PM »
We are using pools, but i will have to Check if we sat it up correctly for the cannonballs

There is no rigid body on the player, but great inputs I will look into them tomorrow and return  :)
Game Designer, CEO, Artist
http://2ndStudio.com

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4948
    • View Profile
    • jinxtergames
Re: Player goes through the floor
« Reply #6 on: July 29, 2017, 01:03:41 PM »
Quote
Last bump here, try.

Go to "Edit > Project Settings > Time" and reduce the 'Fixed Timestep'

Change it to a smaller value, like 0.01. It will cost a bit in performance but should keep objects from passing through each other under fast speeds, if simply changing the collision detection to continuous dynamic (which should be the first thing to try) didnt work.

i just read this now, i actually just recently made an action for some to use this @ runtime, look at this post it might be useful. and if you use it give me some feedback :D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15205
  • Official Playmaker Support
    • View Profile
Re: Player goes through the floor
« Reply #7 on: July 31, 2017, 11:55:41 AM »
Hi,

 Is it not a case where the fixedTimesteps are too few and you need to increase it so that the physics engine iterate more per frame and thus don't miss the floor.

 it happens also when you have your colliders exactly positioned, it's better to have ti slightly off the ground so that when it starts it has time to rest. Maybe raycasting suffer the same issues when perfs is affected.

Did it happened before or it just came as a new issue recently? can you see any potential link with Unity update?

also when are you doing the raycast? lateupdate?

 Bye,

 Jean

DennisJensen

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Player goes through the floor
« Reply #8 on: August 10, 2017, 01:07:21 AM »
Guys sorry about the late reply. It's been busy, phew...

@tcmeric:
The script you forwarded didn't work in this case since we don't use a rigid body. But I played around with the time settings and the biggest issue is that it could skip a series of frames, by lower the "maximum allowed Timestep" it resolved the issue, but if you run the game on a bad computer everything will be in slow motion. Not sure what to do about that. Since we can't control if people set their settings on high and then run 20 fps on a bad computer. It would be a problem for our Online multiplayer part.

@jeanfabre:
Hmm... I do have a bit of a treshold but I'm positive it's because if there is lag it doesn't detect the hit, it goes through it in one frame I guess. It's always been a problem we used rigid bodies before it was the same.

Regarding late update , there is no setting for it in ray casting but I think I read that it was always late update?

Thanks guys :)
Game Designer, CEO, Artist
http://2ndStudio.com

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15205
  • Official Playmaker Support
    • View Profile
Re: Player goes through the floor
« Reply #9 on: August 10, 2017, 01:57:31 AM »
Hi,

 Could you make colliders bigger in size so that your player going trhough is not suffering the typically miss for a bullet going trhough a wall too thin to be detected between frames.

http://answers.unity3d.com/questions/532654/bullets-going-too-fast-and-passing-through-collide.html

Maybe the key is also to optimize your fps. On many projects I created some perfs watcher and simply alerted the user when FPS was too low, saying "look we can't really guarantee it's going to be ok with such a low perf" and then propose several quality optimizations options to turn off and regain fps. You could automate this process as well with a priority list of features to turn off when fps is too slow.

Let me know if you want to take this further and pm me, It would be good you can fix this, I am ready to help.


Bye,

 Jean

DennisJensen

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Player goes through the floor
« Reply #10 on: August 21, 2017, 02:52:40 AM »
We just had a weekend filled with testing and lowering the max fixed timestep solved the problem since now it can't skip a frame, however if it does lag the whole game is in slow motion :) So we just need to keep it optimized :D
Game Designer, CEO, Artist
http://2ndStudio.com

terri

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • terrivellmann.tumblr.com
Re: Player goes through the floor
« Reply #11 on: August 21, 2017, 03:02:41 AM »
when does the bug happen in the video exactly?

won't work for the castle bricks but if the player is falling through the flat ground you could also just be checking the Y position, and if its lower than the ground you can hard set it to the minimum. might look a bit weird for a frame or two but it won't break the game at least

also, I've made a game where you had rockets with smoke trails like you do, and one tip is to keep the smoke and the projectiles separate so when you destroy the projectile the smoke trail doesn't disappear suddenly

DennisJensen

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Player goes through the floor
« Reply #12 on: August 25, 2017, 01:01:03 AM »
@Terri
Yeah that could also be a solution, but currently we don't see the bug anymore, which is great :) So I don't think we need to do that.

Regarding the smoke trail, yes that's something I have been thinking about too. Thanks for the input.
Game Designer, CEO, Artist
http://2ndStudio.com

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 747
    • View Profile
Re: Player goes through the floor
« Reply #13 on: August 25, 2017, 02:24:07 AM »
Not sure if you are using a pooling solution? But I am using pooly, which is nice for spawning pool objects. But it also has a cool script that you can add to prefab particle effects, which destroys them (puts them back into the pool), once they are done. Otherwise I used to have keep my parent game object alive to despawn them. Now that script can do it for me, and I can safely kill the parent (actually i pool that too!).

DennisJensen

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Player goes through the floor
« Reply #14 on: September 27, 2017, 08:10:26 AM »
Thank you,

I think we have plenty of stuff right now we need to look into, since the game is also launching soon on steam in closed Alpha :)
Game Designer, CEO, Artist
http://2ndStudio.com