Answer
Posted by Flamez53
Last Updated: January 14, 2016

So i'm programming in the unity3d engine and i can't move on because im stumbling on a pervasive error.

 

using UnityEngine;
using System.Collections;

public class ScriptPlayer : MonoBehaviour {

    // Use this for initialization
    void Start () {
    
    }

private     string tagName;

public       float Raycast = 0F;


    // Update is called once per frame
    void Update () {

    // Use Mouse Button to Select GameObjects
        if (Input.GetMouseButtonDown (0)) {
        

                        RaycastHit hit;

                        Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
                        
                    if (Physics.Raycast (ray, out hit, 104)){

                    if (hit.transform.tag == "Player"){

    var              enemyScript = transform.GetComponent(ScriptEnemy);

    var                enemyScript.Clicks  -= 1;

            
                } else {
                
                        print("enemy");
    

                    }
                }
            }
        }
    }

 

Is there anything wrong with my code??

Related Content