• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Apr 25, 2018 at 11:51 PM by S_jay1 for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by S_jay1 · Jan 17, 2018 at 02:29 AM · collisionrigidbodycolliders

Why does my player fly through my barrier?

I want to create an invisible barrier that my player will just bump into if it collides into it. I followed this thread to create my barrier https://answers.unity.com/questions/52283/invisible-walls.html. It works pretty well for the most part except for the fact that if I keep bumping into the wall, the player can go right through it. How would I fix this?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Buckslice · Jan 17, 2018 at 02:36 AM 0
Share

The page you linked doesn't work. $$anonymous$$ake sure you aren't editing the transform of the player directly and ins$$anonymous$$d move it by changing the rigidbodys velocity or using the Rigidbody.$$anonymous$$ovePosition function.

2 Replies

  • Sort: 
avatar image
0

Answer by Ginxx009 · Jan 17, 2018 at 02:36 AM

First thing to check if do all your invisible barrier have Colliders on them? Are the Collider's "Is Triggers" box clicked on?

Second thing If you have a Rigidbody and all the proper Colliders and you're not ignoring the collisions via code or anything like that.. Try setting your Rigidbody's Collision Detection to "Continuous".

Discrete Detection: Checks the next frame "Is the collider touching another collider in this frame? If not, move there, if so, we collided"

Continuous Detection: Fires a Raycast in the direction of movement to check the collision before they happen.

And Third is please post your code in the reply section so i can help you with the code . Cause maybe it is your problem

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image S_jay1 · Jan 17, 2018 at 04:02 PM 0
Share

I checked the "Is Trigger" box for the Collider and this caused the player to die when it touched the collider. I set the Collision Detection to Continuous but it doesn't seem like it did anything. This is the code I have for the barrier:

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class BarrierController : $$anonymous$$onoBehaviour {

 // Use this for initialization
 void Start () {
     GetComponent<Rigidbody> ().velocity = new Vector3 (0, 0, 7);
 }

}

This is the code for the Collision: using System.Collections; using System.Collections.Generic; using UnityEngine;

public class DestroyContact : $$anonymous$$onoBehaviour {

 PlayerController player$$anonymous$$ovement;
 CameraController camera$$anonymous$$ovement;
 public GameObject player;

// public Camera camera; public ParticleSystem particleSystemPlayer; public Vector3 PosofDeadPlayer;

 void Awake()

 {

     player$$anonymous$$ovement = GetComponent <PlayerController> ();

// camera$$anonymous$$ovement = GetComponent(); }

 void OnTriggerEnter (Collider other)
 {
     if (other.gameObject.tag == "Floor") {
         return;
     }
         
     if (other.gameObject.tag != "Floor") {
         Destroy (gameObject);
         PlayerisDead ();

 
     }

 }



 void PlayerisDead()

 {
         player$$anonymous$$ovement.enabled = false;
     //    camera$$anonymous$$ovement.enabled = false;
         PosofDeadPlayer = player.transform.position;
         particleSystemPlayer.transform.position = PosofDeadPlayer;
         particleSystemPlayer.Play (true);
 }

}

avatar image
0

Answer by huppatzd · Jan 17, 2018 at 03:00 AM

Rigidbody > collision detection > continuous

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

138 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to make an animated object interact with a rigidbody? 1 Answer

stop objects moving through each other 5 Answers

Character is not Colliding despite having a Box Collider and Rigidbody 0 Answers

Instantiated object not colliding when not have a rigidbody?? 2 Answers

Adding components to 3d models 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges