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
0
Question by WillNode · Dec 31, 2014 at 12:27 AM · c#physicsraycastcolliderstatic

Determine object hitting a static collider at update()

So I have a Sphere Collider for my player and I want to make my player always saving variables (for checkpoints) when my player stays or rolling in a static object.

so my question is, how to determine that this object are hitting an object with Static Collider within an Update() function?

Comment
Add comment · Show 7
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 BMayne · Dec 31, 2014 at 12:37 AM 0
Share

Do you need the collider or do you just want to know if it's in range?

avatar image WillNode · Dec 31, 2014 at 12:52 AM 0
Share

i just want to know if it's collider hit my player, i don't need any collider info (but i want to know it's collider are static or not)

avatar image Oliver1135 · Dec 31, 2014 at 01:03 AM 0
Share

a collider is static if it does not have a rigidbody (or rigidbody2d in 2d case)

avatar image WillNode · Dec 31, 2014 at 01:31 AM 0
Share

yes, i know, so how i can achieve this?

avatar image Oliver1135 · Dec 31, 2014 at 01:41 AM 1
Share

I'm not entirely sure how to do that in the UpdateFunction, you could do a linecast to all the checkpoints in the scene and check if the distance of the linecast is within a bound such that you would perform your UpdateVariables() with that checkpoint

I'm not sure why you have to perform the check in the Update()

Sorry for not directly answering the question you're asking but is there any specific reason you are not able to do something like below because even if you check somehow in your Update() you need to know if the thing you've collided with is actually a checkpoint so you'll need to check the tag, all which is handled with the OnTriggerEnte/OnCollisionEnterr

 OnTriggerEnter(Collider other)
 {
 if (other.tag == "Checkpoint")
 UpdateVariables();
 }

Sorry I couldnt be more help

Show more comments

1 Reply

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

Answer by BMayne · Dec 31, 2014 at 01:51 AM

Hey there,

You can do this by using Physics.SphereCast. I would suggest using layers too.

http://docs.unity3d.com/ScriptReference/Physics.SphereCast.html

Regards,

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 WillNode · Dec 31, 2014 at 02:04 AM 0
Share

i sorry to ask you again, but how i fill the layer$$anonymous$$ask parameter? in the documentation there is something like Bit Shift that i didn't understood it well

avatar image BMayne · Dec 31, 2014 at 02:06 AM 0
Share

Without knowing how bit shifting works you can just do this Layer$$anonymous$$ask.NameToLayer("The name of the layer you want to check");

avatar image WillNode · Dec 31, 2014 at 02:23 AM 0
Share

thanks... seems there is no better answer (for now).

i will mark this as solved if there is no better answer.

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

27 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

Related Questions

Slant Physics Raycast Implementation 0 Answers

Particular collider not working properly... 1 Answer

Changing object scale without changing collider scale 1 Answer

AI Players Movement for Rolling Ball Game 0 Answers

methods for mouse picking that do not use physics? 1 Answer


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