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 CazicThule · Aug 24, 2012 at 07:24 PM · collisionraycastposition

Is it possible to cast a ray but ignore Z position?

Say I have a '3D' platformer that is viewed from a side-on perspective, I want to shoot a ray down from the player and see if there are any platforms below him on the X plane, regardless of their Z position. Is this possible?

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
3
Best Answer

Answer by Fattie · Aug 24, 2012 at 08:06 PM

That's a good question !

Not that I know of ... I don't think there's a way to "flatten cast", which would be clever in PhysX (but I'm struggling to think of much utility for it outside of 2.5D !)

normally in a 2.5D production, you'd have all the "relevant things" in the same z plane....

But here's a trick:

the colliders/triggers you have on your objects...

There's no reason they cannot be QUITE DEEP!!

for example, you have "clouds" on "layer 6" (6m from the camera) and "spaceships" happen to be on "layer 7" (7m from the camera). You want to cast from one to the other .... just made the colliders a couple meters deep in each case.

Another idea on the same ... always make ALL your colliders deep enough to cover ALL your "layers" !

Don't forget too, it's very easy to SHOOT A FEW RAYS.

So in the example if you are in layer 5, and you are concerned about objects in layers 5 AND 10 AND 15 ... simply shoot three rays from where you are, in those three layers.

Makes sense ?

(BTW by "layers" I simply mean indeed the z distance from the lens. often in a 2.5D production they'll get to seem like different functional "layers" to you.)

A final point ... when you're doing such a production, you have to ask "what should you put in the various layers". Certainly the answer is pretty much "stuff you'll have to cast against and collide with each other should all go in the same layer!!" So really that could be a better answer depending on your situation.

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 CazicThule · Aug 27, 2012 at 03:59 PM 0
Share

It seems the best thing to do is simply extend with Z size of each collider

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

7 People are following this question.

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

Related Questions

Using Trigonometry for Collision Detection 0 Answers

Move object with mouse without passing through colliders 0 Answers

Physics.SphereCast please help understand 0 Answers

how to I zero out a parented child's position in X,Y,Z on collision? 1 Answer

Predicting hit coordinates of a moving object 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