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 /
avatar image
0
Question by Colorfusion · Jul 11, 2011 at 03:13 PM · collisionraycastwallthrough

Going through wall

I need help in building a script for my game, I want to allow the character to be able to pass through a wall by targeting a wall using raycasting as the starting point, from that starting point make a ray or something that targets the area after the wall. Then the player walks toward the starting point and then the player gets teleported across, and able to access to and fro.

But how do I code the part where I create 2 points by targetting a wall, one on the side where the player is facing and the other side of the wall where the player is supposed to teleport across?

Here is an example of what I mean if you don't fully understand what I am trying to do.

1| wall | 2

So when I aim at the wall and it creates the start point at 1, I want to script 2 to appear at the other side of the wall.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by sneftel · Jul 11, 2011 at 03:24 PM

Once you use Physics.Raycast to identify the entry point, you can use the Collider.Raycast function (not the Physics.Raycast function) on the wall with a second ray going in the other direction. The origin point should be far enough along the original ray that it won't be inside the wall, and the direction is negated.

Comment
Add comment · Show 6 · 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 Colorfusion · Jul 11, 2011 at 04:00 PM 0
Share

I don't quite understand how Collider.Raycast works even after reading unity references, would you $$anonymous$$d explaining?

Assu$$anonymous$$g I use Fire1 to send a ray towards the wall, how am I supposed to script Collider.Raycast to project a ray through the wall to the other side? As in the direction and also the distance?

avatar image sneftel · Jul 11, 2011 at 05:02 PM 0
Share

You call Collider.Raycast on a collider, and you pass it a ray, and it tells you where the ray hits the collider.

I'm not sure how to explain further... the second ray is on the same line as the first, but pointing in the other direction. One ray starts on the left side of the wall and points towards the wall; the other starts on the right side of the wall and also points towards the wall.

avatar image Colorfusion · Jul 11, 2011 at 05:07 PM 0
Share

Is it possible that I use Collider.Raycast to start from the point where I hit the wall using Physics.Raycast and then cast a ray through the wall and then returns me another hit value that records the position on the other side of the wall?

avatar image sneftel · Jul 11, 2011 at 05:37 PM 0
Share

No, it is not.

avatar image Colorfusion · Jul 12, 2011 at 02:57 AM 0
Share

So when I use Physics.Raycast towards the wall on the left side, how do I call Collider.Raycast on the right side?

Show more comments
avatar image
0

Answer by manlymen361 · Nov 20, 2011 at 10:12 AM

create a camera and make a new layer called gun then put that camera u just created to the layer gun and put ur weapons to the layer gun and make sure that camera is on depth only and change the depth to 1 and there u go

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Camera looking through objects when touching 1 Answer

RigidBody stuck on wall when jumped against 7 Answers

object goes through walls(no, dats nnot what r u thinkig about) 0 Answers

Detecting collision on start in my building system 0 Answers

Detecting collisions with raycast or not? 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