Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
4 captures
13 Jun 22 - 14 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 /
This question was closed Feb 13, 2021 at 10:36 PM by GgJmGg for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by GgJmGg · Feb 13, 2021 at 08:45 AM · anglebulletfloatcoordinates360-degrees

Float to angle coordinate?

I have a code that detects an angle and send out a float between 0 and 360 degrees called fAngle.

what I want to do is shoot a bullet with a rotation = to that float, so, if my player is looking up, the bullet would go up because fAngle = 90

Im new to programing so, if anyone has the answer scripted. It would be great. Because I have no idea how to use a quaternion,I have a code that detects an angle and send out a float between 0 and 360 degrees called fAngle.

what I want to do is shoot a bullet with a rotation = to that float, so, if my player is looking up, the bullet would go up because fAngle = 90

Im new to programing so, if anyone has the answer scripted. It would be great.

Comment
Add comment · Show 1
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 GgJmGg · Feb 13, 2021 at 05:47 AM 0
Share

because i have no idea how to use quaternions

1 Reply

  • Sort: 
avatar image
0

Answer by Llama_w_2Ls · Feb 13, 2021 at 08:55 AM

You don't need to know much about quaternions, and how they work because you can use the static methods that the Quaternion struct provides, for example, Quaternion.Euler, which returns a rotation x on the x axis, y on the y axis, and z on the z axis, respectively.


Essentially, it's a way of converting a euler angle (90 degrees) into a quaternion (0, 1, 0 ,0 or smt). For example:

 float yDegrees = 90f;
 
 // Returns a rotation 90 degrees on the y
 Bullet.transform.rotation = Quaternion.Euler(0, yDegrees, 0);

@GgJmGg

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 Llama_w_2Ls · Feb 13, 2021 at 08:56 AM 0
Share

There are lots of other ways, that I would recommend instead, such as Quaternion.LookDirection(Vector3 direction), which returns a rotation, that makes an object face a direction. For example, if your gun fires a raycast, you can use the direction of the raycast to orientate your bullets to face the same direction as the gun.

avatar image GgJmGg · Feb 13, 2021 at 06:33 PM 0
Share

Thanks! it worked by puting the float on the z axis (2d game)

avatar image GDGames0302 · Feb 13, 2021 at 06:58 PM 0
Share

Hi. If you found the correct answer, please mark this question as closed. Thank you.

Follow this Question

Answers Answers and Comments

114 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

Related Questions

Determining the angle of a projectile collision. 2 Answers

Perfect bullet spread for top-down shooter 1 Answer

Shooting. Bullet floats and sprays 1 Answer

get Pitch and Roll values from object 3 Answers

Finding the Angle Between Two Objects in 360 Degrees. 3 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