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 /
  • Help Room /
avatar image
0
Question by ZebMastaH · Sep 11, 2020 at 06:42 AM · shootingweaponcrosshair

Circle crosshair that fits the bullet spread

Hello, I’m building a game where the guns have a circle crosshair that indicate the bullet spread. It is supposed to work with the players current weapon skill. Example: Player has 0 skill in assault rifles, his crosshair is gonna be very big and so is his bullet spread. When reaching higher levels in assault, his circle narrows down and so does the bullet spread. I am very beginner and starting to make an FPS game and I want to start with this part because it has a huge impact and is one big essence of the game! How can I achieve this? Pointers to reading material, tutorials, code samples are appreciated

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 streeetwalker · Sep 11, 2020 at 09:30 AM

This is really simple to do using a number of approaches.

One way that may be the simplest is to create the crosshair graphic and import it. Then create a material and use the crosshair graphic for the albedo texture. Then use the material on a plane.

Drag the plane with the crosshair texture material applied to the project folder, say in a prefab folder, to create a prefab out of it. Make sure the prefab origin is at 0,0,0 and it's scale xyz are all set to 1,1,1..

You can then instantiate this where ever you want (or author it driectly into your guns). and to set different spread sizes, set the transform.localScale = new Vector3( xS, yS, zS ) where xS, yS, zS are all the same number. For example, 1 is original size, 0.5 is half size, 2 is double size, and so on.

If you are authoring it directly into the gun, you can just resize it in the inspector or using the scale tool without any script.

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 ZebMastaH · Sep 11, 2020 at 02:54 PM 0
Share

Okay I think I understand, it is basically a picture set onto a plane that I show in the interface somehow. But since it’s a picture, how can I then find the circle outer bounds from the picture size? I’m guessing I have to know the exact size of the circle to perform some kind of raycasting and calculate the bullet spread right? Would it be easier to create some kind of circle object that has the correct proprieties and calculate a raycasting from it? Wild guessing here

avatar image streeetwalker ZebMastaH · Sep 11, 2020 at 03:37 PM 0
Share

if you put the circle graphic in a material, and place it on a plane or flattened cube of size 1, it's size will be 1.

Now you can use that to deter$$anonymous$$e the actual bullet spread - you don't need raycasts, just line equations. (raycasts are expensive!). So you can calculate how the bullets expand as they move outward. Your bullets will need colliders to effect a hit.

avatar image ZebMastaH streeetwalker · Sep 12, 2020 at 05:29 PM 0
Share

Aha okay I will try it out as soon as i can and get back here to you! Thanks!

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

214 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Shooting exactly to the center of screen 0 Answers

How to aim at crosshair in a 2D game? 0 Answers

How to make gun shoot in the crosshair 0 Answers

weapon Spread 0 Answers

Shots don´t go forward 0 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