Search Unity

Collision problems

Discussion in 'FPS.Sample Game' started by MaverickROM, Aug 1, 2019.

  1. MaverickROM

    MaverickROM

    Joined:
    Mar 19, 2019
    Posts:
    11
    Hi everyone,

    I've been trying to work this out for days now and it's doing my head in. I've got a building (that's an imported asset) whereby my character can walk through some of the walls, and a set of swinging doors working off built-in physics (hinge joints and colliders) are acting as solid barriers. Everything works fine in the sample scene the asset came with which of course is using a first person controller and is not ECS.

    I can't work out why some of the walls aren't colliding as expected; I would have thought that as static objects they should just work.

    I'm also stumped as to why the doors aren't swinging when the character walks into them. My current thinking from reading other posts here (thanks @AggressiveMastery your posts are always really helpful) is that I need to set the doors up as replicated scene entities to allow the server to control their movement.

    Can anyone help point me in the right directions here? Thanks in advance.
     
  2. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206
    Hello @MaverickROM Thank you for the call out! :)

    You are heading in the right direction. Static normal-physics objects/colliders will work with the example. But be sure they are setup. Your asset might have floors/walls setup differently that you are expecting, so go through and be sure its all set to the right layers and ect for models/colliders. Generally, imported normal game assets (like houses) should collide fine, except for the DOORS.

    Moving objects, such as doors, are totally different. You need to check out the Mover job system and scripts. There is a Cube Prefab (search for "cube") that you can put/spawn in your server and the clients will update with the position. Using that, you can assign it to a door, so that instead of updating the cube location... you update the "cube" that is the door's location. You also want to be sure to run the editor as SERVER, and have a client connected, so you can see the differences and how the code works. Running in "play" doesn't work correctly when doing network tests (aka movable objects.) Play can show static items, such as grass, animations, lighting, hdrp stuff, but networked things should be tested with server and client connected and viewed from both sides by you.

    You will also need to work out how your doors work. If you run a server-side "on collision/trigger" you can get the doors opening and syncing automatically with just the mover script attached to them... however, if you want a "press e to open" you will need to write a "runonserver" command and system. To check when a client wants to "e" something, what "e"-able objects are in collision with that player such as a door.

    I hope to start work on this myself soon, but can't commit to anything. I am a one man army.

    Cheers and Good Luck!
    Micah
     
  3. MaverickROM

    MaverickROM

    Joined:
    Mar 19, 2019
    Posts:
    11
    Sweet, thanks Micah. I'll persevere and if I get something working I'll share.
     
  4. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206