Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Bunnybomb7670 · Sep 04, 2016 at 03:29 PM · physicsraycastraycasting

Strange physics raycasting behaviour

Hi,

I have a little pooling script for a small project I am working on, when you click, the collision box is teleported away, to remove the collisions for that block, however I seem to be running into a weird raycast issue. When I teleport the block it seems like the raycast still picks up the blocks previous position.

A short GIF of the issue can be found here: http://puu.sh/qZFDP/9d7bed3859.gif

Is there another cause for this happening or is this a bug? The following code is used to raycast the point :

 RaycastHit hit;
             Ray r = new Ray(transform.position, transform.forward);
 
             if (Physics.Raycast(r, out hit))
             {
                 cursorPointer.transform.position = hit.point;
             }
             else
             {
                 cursorPointer.transform.position = transform.position;
             }

Comment
Add comment · Show 14
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 doublemax · Sep 04, 2016 at 03:42 PM 0
Share

There isn't much you can do wrong when raycasting. Please show the object hierarchy and how you hide the block.

avatar image Bunnybomb7670 doublemax · Sep 04, 2016 at 03:45 PM 0
Share

Did you get a chance to look at the GIF I posted? I teleport the collider to (100,100,100) just to test.

avatar image doublemax Bunnybomb7670 · Sep 04, 2016 at 04:01 PM 0
Share

So you just change the position of the collider component? What about the object itself?

I would try to just to set the whole gameobject to non-active.

Show more comments
Show more comments
avatar image Bonfire-Boy · Sep 04, 2016 at 05:52 PM 0
Share

Have you checked what object the raycast is hitting?

avatar image Bunnybomb7670 Bonfire-Boy · Sep 30, 2016 at 08:18 PM 0
Share

From what I understand, It hits that actual object that is teleported away, It just seems to think that it still exists in the same place. It's bizarre behaviour that I've never run into before and I want to think that it is my own issue, I just never found a way to explain it.

avatar image Bonfire-Boy Bunnybomb7670 · Sep 30, 2016 at 08:39 PM 0
Share

"From what I understand", doesn't make it sound like you're convinced. Have you actually logged its name, for example?

Show more comments
avatar image Owen-Reynolds · Sep 04, 2016 at 07:05 PM 0
Share

I'd guess the raycast is perfect, but something else, not shown here, in your code is wrong. When you move the object, there's probably a delay until you run the raycast again.

I've seen funny "takes an extra frame" issues when moving things, but never (in recent Unity's) with a raycast. I've found I can move any sort of collider in/out one line before the raycast, and it always works.

avatar image Bunnybomb7670 Owen-Reynolds · Sep 30, 2016 at 08:19 PM 0
Share

The raycast is per frame and the cube is teleported away once and pooled, no other teleporting occurs. You can see that it is per frame as it continually moves the sphere over the object

0 Replies

· Add your reply
  • Sort: 

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

100 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

Related Questions

How to reflect raycast rays of objects 2 Answers

Best way to get a thickness of a wall between 2 points 2 Answers

Adding MaxDistance to RayCast Stops Raycast From working 0 Answers

alpha Test Treshhold throwing error when alpha > 0 0 Answers

cant get raycast to work with tags 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