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 titovelosa · Jul 29, 2019 at 11:07 AM · unity 2dlinerenderershooteraim

Unity 2d game: How to change aim line (line Renderer) dots?

I am working on a small game project for a shooter with aim line and I was able to make this aim line with Line Renderer but I can't change the shape of that line. I wanted something like little round dots. It seems to me that it would have something to do with the Default-particle in the Inspector Tab but how do I change that stuff? Do I create the material and replace it? if so how?

I put here some images of how the aim line are in this moment, how the Inspector Tab are and my code of the Line Renderer. Thanks so much for some help.

alt text alt text

The code of the Line Renderer:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 [RequireComponent(typeof(LineRenderer))]
 public class Weapon : MonoBehaviour
 {
 [Range(1, 5)]
 [SerializeField] private int _maxIterations = 5;
 
 [SerializeField] private float _maxDistance = 25f;
 
 public int _count;
 public LineRenderer _line;
 public int ammo;
 
 public Transform Firepoint;
 public GameObject BulletPrefab;
 public GameObject FirePrefab;
 
 
 private void Start()
 {
     _line = GetComponent<LineRenderer>();
 }
 
 // Update is called once per frame
 private void Update()
 {
 
     if (Input.GetButtonDown("Fire1") && ammo > 0)
     {
         Shoot();
     }
 
     _count = 0;
     _line.SetVertexCount(1);
     _line.SetPosition(0, transform.position);
     _line.enabled = true;
     RayCast(transform.position, transform.right);
 }
 
 private void Shoot()
 {
     //shooting logic
     var destroyBullet = Instantiate(BulletPrefab, Firepoint.position, Firepoint.rotation);
     ammo--;
     Destroy(destroyBullet, 10f);
     var destroyFire = Instantiate(FirePrefab, Firepoint.position, Firepoint.rotation);
     Destroy(destroyFire, 0.3f);
 }
 
 private bool RayCast(Vector2 position, Vector2 direction)
 {
     RaycastHit2D hit = Physics2D.Raycast(position, direction, _maxDistance);
     if (hit && _count <= _maxIterations - 1)
     {
         _count++;
         var reflectAngle = Vector2.Reflect(direction, hit.normal);
         _line.SetVertexCount(_count + 1);
         _line.SetPosition(_count, hit.point);
         RayCast(hit.point + reflectAngle, reflectAngle);
         return true;
     }
 
     if (hit == false)
     {
         _line.SetVertexCount(_count + 2);
         _line.SetPosition(_count + 1, position + direction * _maxDistance);
     }
     return false;
 }
 }



67257295-364311204255825-7419182964455505920-n.jpg (105.8 kB)
67242676-438924210030504-8793574633774252032-n.jpg (105.2 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

110 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

Related Questions

Having problem with killing aliens in Space Invaders. 2 Answers

Third Person Aiming 0 Answers

Unity 2D -Reflecting a linerenderer 2 Answers

How to Fix "NullReferenceException"? Aim Down Sights Script 1 Answer

Move to line 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