Forum rules - please read before posting.

Walking through the furniture

One game object in my game, downloaded from the Asset Store and used straight from the box, is a bed. My player can walk up to it but not through it, which is just as it should be. It has a transform and an animator (not sure why as it's inanimate) but no colliders. Elsewhere I have a group of tables and chairs which are enclosed in a box collider with Target checked, another box collider with Target unchecked, and a navmesh. Despite this my player can walk right through the furniture. My question is, how do I ensure that solid objects cannot be walked through?

Comments

  • I assume you are talking about 3D? You need to make sure your objects have a non trigger collider, static objects don't really need a rigid body but your moving objects, like your character, should have one to detect collision. Specially, make sure the collider enclosing that furniture isn't set as a trigger. Also collisions are affected by the speed of the objects. If you player is too fast and your objects' or player's rigidbodies are set to detect collisions discreetly, then the reaction may be too slow to detect the collision at all.
     
    About the bed it must have a collider in it, it might just be a mesh collider or it might be in one of its children (in case it's made out of parts, check if you can open it in the hierarchy). It could be that your player doesn't have a rigidbody for some reason, but one of the children in the bed does have a rigidbody (remember that at least one of the two colliding objects needs to have a rigid body to register collisions).
  • Thanks Alverik. You are quite right about the bed - it has a frame as a child, and that has a mesh collider. My player does have a rigid body and the box collider on the tables is now not set as a target, but the player still walks through it. What else can I try?
  • What's your movement method, Point And Click or Direct?  Your Player will also need a collider of his own (a Capsule Collider) in order to collide with objects.

    Your NavMesh will need to account for the furniture, so you'll need to re-bake it once your scene's colliders have been tagged as Navigation static.
  • The movement method is first person. The player object does have a capsule collider. How do I tag the scene's collider as Navigation static? Do I add a new tag called Navigation static? To every object in the scene?
  • No, I'm referring to Unity's built-in static tag, mentioned here.

    However, in the case of First Person movement, pathfinding is only relied upon when AC is moving NPCs, or moving the Player during Cutscenes (i.e. out of the player's direct control).  During gameplay, where the Player can and cannot move will be determined purely by colliders, so if the player is clipping through geometry it will be due to the colliders not being correctly assigned.

    This then is more of a Unity issue, as AC is relying on Unity's Physics/Collision systems, but you can use AC's CollisionCube prefab to quickly lay down areas the player cannot move to.  The First Person tutorial video covers this, if you haven't yet seen it.
  • Thank you. I have seen the tutorial and I have set up a CollisionCube prefab to completely cover a game object, but my player can still walk through it.
  • We will need to see screenshots of these colliders and your full Player Inspector then.  Does the collider on your Player (which should also have a Rigidbody) have "Is Trigger" unchecked?
  • I've not been able to upload screenshots here, so I've emailed them to you. Is Trigger is unchecked on the Player collider
  • Images can't be uploaded on the forum's server, but they can be hosted on image-hosting sites such as imgur.com.
  • I've spent several days on this problem. I have a fully working game which I think is quite good. The mechanics work well, the puzzles are good, the graphics are convincing and the story is intriguing. However, the illusion of being in and moving around different rooms is totally destroyed by the fact that the first person player character can plough straight through all the game objects and walls. I've tried a lot of possible solutions but none of them work.  This is a puzzle, because it would make more sense if none of the objects could be walked through unless deliberately made that way.  I have run out of ideas to solve this now so I have decided - reluctantly - to abandon the game and go on to something different which won't have this problem.  Maybe a platformer or an endless runner.  Not my preferred way to go but as I said, I can't think of anything else.
  • @Mike This is almost certainly a general Unity issue, rather than one specific to AC, and should be quite solveable.  If you would wish for me to see the scene for myself, please PM me a .unitypackage file containing it, along with your Player prefab and Manager asset files.
  • edited January 2017
    True, this is not an AC issue, there's probably something missing from Unity's basic collision system in your player or the objects. Or the player's rigidbody could be set as kinematic or something (which would make him ignore collisions when moved), same if the colliders on the player or the objects are ticked as "Trigger". But without inspecting the scene or the objects it will be hard to know what's wrong. It would be easier if we could see at least a video with a side by side shot of the play window and scene window. Or like Chris said, a repro project with one of the scenes or a basic version of one of the scenes.
  • Thanks Alverik. I've sent Chris a .Unity file. I'm quite happy to share any files with you. How would I take a video of the game running? Record the laptop with my iPad?
  • edited January 2017
    Just browse the internet for a free screen recorder (some are mentioned here or here). Then you can upload the video to youtube or any other hosting site and share the link. I guess you could take the video with a phone or Ipad but you'd have to make sure it's not shaky or blurry (so it's not hard to read the text in the inspector and hierarchy).
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.