x


targetting dont work

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {
public playerTarget Transform;
public pa PlayerAttack = GetComponent("PlayerAttack");
//empty RaycastHit object which raycast puts the hit details into
public hit RaycastHit;
//ray shooting out of the camera from where the mouse is
public ray Ray = Camera.main.ScreenPointToRay(Input.mousePosition);

void Update() {

//check if the left mouse has been pressed down this frame
if (Input.GetMouseButtonUp(0)) {



    if (Physics.Raycast(ray, hit)){

    if (hit.collider.gameObject.CompareTag("Enemy")) {

    //print out the name if the raycast hits something

        Debug.Log(hit.collider.name);

        playerTarget = hit.collider.transform;

        Debug.Log("PlayerTarget Successfully changed");

        pa.target = playerTarget;

    }
    else{

        Debug.Log(hit.collider.name + " no tag");
           }
       }
    }
}

}

it dont work so pls help

im work in c# not java scipt

more ▼

asked Jun 30 '12 at 09:53 AM

jfire1998 gravatar image

jfire1998
0

What about it doesn't work? Does it throw an error? Does it do anything? Does it even compile?

Just pasting a wall of code and stating it doesn't work won't get you anywhere.

Also please format it correctly.

Jun 30 '12 at 10:57 AM Piflik
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2031
x563
x151

asked: Jun 30 '12 at 09:53 AM

Seen: 188 times

Last Updated: Jun 30 '12 at 03:36 PM