x


C# FlashlightScript?

I am trying to make a horror game that when you turn on your flashlight, the monster runs faster. But the problem is, the AI script im using is in C# but the flashlight script is in javascript. Ive tried to make a flashlight script in C# but none of them worked.

Do I need to change the code to C# or is there a way to link C# and JavaScript together?

Heres the AI script just in case it might help:

 public Transform target;

public int moveSpeed; public int rotateSpeed;

private Transform myTransform;

void Awake() { myTransform = transform; }

// Use this for initialization void Start () { GameObject go = GameObject.FindGameObjectWithTag("Player");

target = go.transform; }

// Update is called once per frame void Update () { Debug.DrawLine(target.position, myTransform.position, Color.red);

//Look at the Target myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotateSpeed * Time.deltaTime);

//Move towards the Target myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;

} }

Plese Help!

more ▼

asked Jul 17 '12 at 09:07 PM

lunyrobot gravatar image

lunyrobot
36 1 1

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Thanks SOOOO much!!!! Sorry about the code box thing. Some thing weird happened and it only Did part of the code

more ▼

answered Jul 18 '12 at 02:22 PM

lunyrobot gravatar image

lunyrobot
36 1 1

(comments are locked)
10|3000 characters needed characters left

hallo, if remember right I have found this in YOUtube hope can help you

when you post a script please code it

selecting the code then click on 101010 button

using UnityEngine;
using System.Collections;

public class FlashLight : MonoBehaviour{

   private bool FlashLights = false;


   void Start () { // not sure is needful
   }

   // Update is colled once for frame
   void Update (){
        if (Input.GetButtonDown("Liteonof") && FlashLights == false){
        FlashLights = true;
        light.intensity = 3;
       }
       else if(Input.GetButtonDown("Liteonof") && FlashLights == true){
        FlashLights = false;
        light.intensity = 0;
       }
    }
}
more ▼

answered Jul 18 '12 at 03:03 AM

Ingen gravatar image

Ingen
145 3 11 19

(comments are locked)
10|3000 characters needed characters left

Thanks so much!!!!!

I dont know what went wrong with the code box. It looked fine in the preview

more ▼

answered Jul 18 '12 at 07:42 AM

lunyrobot gravatar image

lunyrobot
36 1 1

(comments are locked)
10|3000 characters needed characters left
Your answer
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:

x5098
x4175
x76

asked: Jul 17 '12 at 09:07 PM

Seen: 494 times

Last Updated: Jul 18 '12 at 02:22 PM