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 aallen170 · Apr 18, 2018 at 10:31 PM · raycastraycastingplatformer

Will I need to use raycasts for my 2D game?

In order to answer this best, I need to explain some mechanics that I want in my game:


  • I plan on making a platform fighter in which each player has the ability to "cling" to walls and jump off them. They can also cling to angled walls and ceilings, being able to jump off those surfaces too.

  • I plan on making the angle at which a wall is "cling-able" to be above 75 degrees. That means that if a wall has an angle of greater than 75 degrees, or less than -75 degrees, a player can cling onto the wall.

  • Considering these mechanics, I was wondering if I'd need to use raycasting to not only calculate the angles at which a player can cling onto a wall, but also calculate the angles the player would jump off a wall based on the wall's angle.


If I don't have to use them, that'd be great since I don't really know how to use raycasts. If I do have to use raycasts based on the mechanics I want for my game, I'd be willing to learn about them, but I'm not sure where I should start to learn about them. I read the Unity documentation, but I don't have a good idea on how to use raycasts practically. I know I'd need to calculate the "noraml" of the raycast to get the angle of a wall, but that's about it.


Also, something that worries me about raycasting is whether or not it'll interfere with collision boxes. Can I still use colliders when using raycasting? Having different colliders for each player will be important since the game is also a fighter, and I'd need to be able to detect when a player's hurtbox collides with another player's hitbox, when two hitboxes collide, etc.

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

Answer by Serinx · Apr 19, 2018 at 02:06 AM

Learning about raycasting is extremely useful in game development. Whether you use it for this problem or some other problem, I'm sure you will use them at some point.

They are fairly simple to use once you understand them. Try watching a few tutorial videos to get the hang of them.

You can use something called a LayerMask which allows you to ignore certain objects when raycasting.

E.g. if you wanted to check the wall angle, but didn't care if another player was in the way you could pass in the layermask for the wall and the raycast will continue through the player and return the hit on the wall.

I highly recommend learning about raycasts, don't be afraid to jump in and learn these things. Unity has made a lot of these functions extremely user friendly and they're there to help you, not hinder you.

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 aallen170 · Apr 19, 2018 at 02:00 PM 0
Share

Yeah I had a feeling it'd be a really useful thing to learn. I'll go ahead and $$anonymous$$ch myself about it. And I'll look into layermasks too. They may be what I'm looking for when considering hurtboxes and hitboxes.

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

116 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 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

Can RaycastHit2D.point be inside a BoxCollider2D if raycast was performed from outside that collider? 1 Answer

Diagonal Raycasting to detect platform returns true, even when false 1 Answer

How do I make raycast ignore the players collider 1 Answer

Raycast not hitting instantiated object when timescale is 0 1 Answer

Rigidbody.position causes shaking 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