• 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 /
  • Help Room /
avatar image
0
Question by ZaddBuzuki · Jan 14, 2017 at 10:58 PM · playercollider2dplayer movementsetactiveontriggerenter2d

How do I Update a Collider's Collison through script?

I have this problem where I have a 2DCircleCollider on my Character, and When you open something like a chest, Items inside the chest Appear by turning the gameObject Active from Inactive. Then, using the 2DCircleCollider around my character, it has the OnTriggerEnter2D function which adds objects within the radius into a list.

But! When an object is within the Radius, and then the Object turns active, it does not activate the OnTriggerEnter2D Function until I move my character in any direction, supposedly updating the fact that they are touching/overlapping.

So my question is, how can I make the OnTriggerEnter2D update the list without having to move my character after objects appear using the SetActive() function?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ZaddBuzuki · Jan 15, 2017 at 02:13 AM

I actually solved it: as well as making the object visible when the player opens the chest, it changes the position of what turns visible on the Z axis, so it is unoticable in 2D, and also moves it back the same amount on two lines of code.

 item.localPosition += new Vector3(0,0,0.01f);
 item.localPosition += new Vector3(0,0,-0.01f);

surprisingly, even doing this, and moving it back to its original position, updates it in the OnTriggerEnter2D, thus making everything run smoothly. Weird fix, but Nothing serious at all.

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

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.

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

92 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

Related Questions

player has two when speed increase in endless runner game 0 Answers

How do I make a 3D player move?,How do I make player movement with jumping? 0 Answers

How make the "player" shoot on the Y axis? 0 Answers

How do I fix my player floating/moving on its own when it hits a wall?,How do I fix my player moving on it's own when 1 Answer

How to identify which collider generated OnTriggerEnter2D 0 Answers

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