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 /
This question was closed Jan 30, 2019 at 11:06 PM by el-mas-pro-470 for the following reason:

Fixed!!!!

avatar image
0
Question by el-mas-pro-470 · Jan 30, 2019 at 07:17 PM · simplearray of gameobjectsautomatickilltargetting

(Updated) How do I make a target system?

Hello, I made a script and updated it, I need to make a system to choose targets within a range, I have the whole system ready but for a single objective that when killing it keeps pointing to it, and clearly is not what I want to do, does anyone Do you know something simple about using the matrix? (That is, an automatic list with all the objectives). Thank you!

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class PlayerAim : MonoBehaviour {
 
     public Transform CamaraTransform;
     public Transform Target;
     public bool LookingTarget = false;
     public GameObject Camara;
     public bool Targeting = false;
     public MonoBehaviour SmoothFllw;
     public GameObject Crosshair;
     public GameObject Player;
     public RawImage Imagen;
     public float Distancia;
 
     void Start () 
     {
     
     }
     
     void Update () 
     {       
         var distance = Vector3.Distance(Target.position, transform.position);
 
         if(LookingTarget == true)
         {
             CamaraTransform.LookAt(Target);
         }
 
         Camara = GameObject.Find ("Camera");
         SmoothFllw = Camara.GetComponent("SmoothFollow") as MonoBehaviour;
 
 
         if(Targeting == true && distance <= Distancia)
         {
             Vector3 TextoPosicion = Camera.main.WorldToScreenPoint(Target.transform.position);
             Imagen.transform.position = TextoPosicion;
             SmoothFllw.enabled = false;
 
             LookingTarget = true;
             Crosshair.SetActive(true);
             Player.gameObject.GetComponent<MouseLook>().enabled = false;
 
         }
         if(Targeting == false)
         {
             LookingTarget = false;
             SmoothFllw.enabled = true;
             Crosshair.SetActive(false);
             Player.gameObject.GetComponent<MouseLook>().enabled = true;
 
         }
     
         if(Input.GetMouseButtonDown(1))
         {
             Targeting = true;
         }
         if(Input.GetMouseButtonUp(1))
         {
             Targeting = false;
         }
     }
 }
 
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

  • Sort: 

Follow this Question

Answers Answers and Comments

98 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

Related Questions

How do I destroy all the GameObjects in an array? 3 Answers

How to find index of colliding Game Object in OnCollisionEnter2D() 2 Answers

Adding Waypoints using a List 2 Answers

how to check if all object in my array are destroyed (C#) 3 Answers

Instantiating array in GameManager upon loading Scene 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