Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
avatar image
1
Question by Dogg · Oct 10, 2014 at 02:35 AM · c#2dglitch

How To Make An Invisible Wall That's Impossible To Get Out Of?

Hello once again awesome people of Unity answers. I have a question that's out of wanting to do it, and curiosity. You see, I want to make an invisible wall that my Player cannot pass through no matter what, but I don't know an effective way of doing that. So far, I use an invisible box collider 2D, and for the most part it seems to do the job. However, recently I've been able to glitch through it and while it doesn't break the game, it does cause me to die. I would just like to avoid dying like that you see. Anyways my box collider 2D isn't really that big, but could that be the reason why I can glitch through it? Or is it another reason? By the way, I'm not the only one who can glitch through box colliders. My Ai can also do it. As a matter of fact it does it all the time. So what can I do? I would love to hear anyone's thoughts/advice.

Comment
Add comment · Show 12
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 KaliTech · Oct 10, 2014 at 02:48 AM 0
Share

Hi, do you $$anonymous$$d providing some more info? I'm currently assu$$anonymous$$g you're using a 2D character. Is that true? If so, you should clamp it's position. EDIT: Oh and is your character moving at a really fast speed? If it is, that may be the cause.

avatar image Dogg · Oct 10, 2014 at 02:55 AM 0
Share

I don't $$anonymous$$d at all. Yes I'm using a 2D character. $$anonymous$$y character does move at high speeds when he goes through the collider. It's like a glitch when I jump, after I jump off a object, my Player blasts off up and goes through the invisible collider. This doesn't happen all the time, but it's a problem that I know needs to be sorted. As for my Ai, it does move at a pretty decent speed too. Oh and sorry for this noob question I'm about to ask, but how exactly does one clamp the character's position?

avatar image KaliTech · Oct 10, 2014 at 03:05 AM 0
Share

It doesn't matter if you're a noob, everyone is here to help or gain knowledge. What plane does your character move on? X axis? Or is it top-down?

EDIT: Here's a link about clamping: http://docs.unity3d.com/ScriptReference/$$anonymous$$athf.Clamp.html

avatar image Dogg · Oct 10, 2014 at 03:11 AM 0
Share

He moves on the X-axis. Left to right. He jumps up, and then falls down. The collider that's he glitches through is on the top, like a ceiling.

avatar image KaliTech · Oct 10, 2014 at 03:18 AM 0
Share

Here's what you can try: transform.position = new Vector3(transform.position.x, $$anonymous$$athf.Clamp(transform.position, floorY, ceilingY), transform.position.z);

(Note: Untested code, written without the use of an IDE)

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Kiwasi · Oct 10, 2014 at 03:12 AM

Fast moving objects and thin colliders is a well know issue. Some options to consider

  • Slowing down

  • Thicker colliders

  • Changing the collision mode on the RigidBody

  • Ignoring physics and using scripts to constrain position

  • Reducing the physics time step

Edit: Added further solutions from comments.

Comment
Add comment · Show 3 · 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 Dogg · Oct 10, 2014 at 03:25 AM 0
Share

So thicker colliders do make a difference? That's what I'm currently trying, so far I haven't been able to run into the glitch, but when I do we'll see if it works.

avatar image Kiwasi · Oct 10, 2014 at 03:46 AM 0
Share

Thicker colliders do make a difference. The glitch is caused by a fast moving rigidbody 'jumping' over a thin collider between physics updates. The thicker your colliders, the faster an object has to be moving for a jump to occur.

Which brings me to another method to solve the problem

  • Reducing the physics time step.

avatar image Dogg · Oct 10, 2014 at 03:52 AM 0
Share

"Reducing the physics time step". Okay I think I know what you mean. I'll see what I can do by messing around with it. Thanks for your help.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

30 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

Related Questions

Multiple Cars not working 1 Answer

GetComponent().enabled = true; 1 Answer

How To Add PlayerPrefs Scores? 1 Answer

Make player not be seen by AI, when player in foilage and shadows. 1 Answer

Starting out C# help 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges