- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
thenachotech1113 · Mar 07, 2013 at 12:50 AM ·
targetlockmissile
how do i make it so when i click on an object it sets it as a variable
hey, i want to make some sort of way to target objects kind of like in bf3 when you lock someone with a missile. basicaly i have no idea on how o make it so when the object is in an specific area of the screen, marked by a GUI it locks it after a few seconds. if some one has an idea on how to make this pls tell me. thank you
Comment
Answer by Snownebula · Dec 30, 2013 at 04:40 AM
Blablabla... target script! As*ho3*$! cant anyone post a freeken answer on here to actually help anyone out? Anyways here is my target script. I got it in a tutorial some where.
> using UnityEngine;
> using System.Collections;
>
> public class Ray1 : MonoBehaviour {
> public string target;
> public GUISkin SkinTarget;
> void Start () {
>
> }
>
> void Update () {
> if (Input.GetButtonDown ("Fire1")) {
> RaycastHit hit;
> Ray ray1 = Camera.main.ScreenPointToRay
> (Input.mousePosition);
> if (Physics.Raycast (ray1, out hit))
> target = hit.transform.name;
> }
> }
> //public float vSliderValue = 0.0F;
> void OnGUI () {
> GUI.skin = SkinTarget;
> GUI.Box(new Rect(25, 10, 200, 200), "Target : " +target);
> //vSliderValue = GUILayout.VerticalSlider(vSliderValue,
> 0.0F, 1500.0F);
> }
> }