Thursday, 2 May 2013

Following AI code update

Hope we have fixed the ai circling bug with this snippet of code.
if we change this part of the previous code

//move towards the player
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;

to:


//move towards the player if not too close

if ( ( myTransform.position - target.position ).sqrMagnitude > 4F )
{

myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;

}
 
it should only move towards the player if the player is a certain distance away so it should in theory stop moving all together if it is so many units close to the player.

Wednesday, 1 May 2013

ColourFilterControl script


public var cameraNormal : GameObject;
public var cameraRed : GameObject;
public var cameraBlue : GameObject;
public var cameraOrange : GameObject;
public var SWITCH_TO_NORMAL_CAMERA_TIME : float = 10;
public class ColorFilterControl extends MonoBehaviour
{
 public static var Instance : ColorFilterControl = null;
 public function SwitchToRedCamera()
 {
  CancelInvoke("SwitchToNormalCamera");
 
  cameraNormal.SetActive(false);
  cameraRed.SetActive(true);
  cameraBlue.SetActive(false);
  cameraOrange.SetActive(false);
 
  Invoke("SwitchToNormalCamera", SWITCH_TO_NORMAL_CAMERA_TIME );
 }

 public function SwitchToBlueCamera()
 {
  CancelInvoke("SwitchToNormalCamera");
 
  cameraNormal.SetActive(false);
  cameraRed.SetActive(false);
  cameraBlue.SetActive(true);
  cameraOrange.SetActive(false);
 
  Invoke("SwitchToNormalCamera", SWITCH_TO_NORMAL_CAMERA_TIME );
 }

 public function SwitchToOrangeCamera()
 {
  CancelInvoke("SwitchToNormalCamera");
 
  cameraNormal.SetActive(false);
  cameraRed.SetActive(false);
  cameraBlue.SetActive(false);
  cameraOrange.SetActive(true);
 
  Invoke("SwitchToNormalCamera", SWITCH_TO_NORMAL_CAMERA_TIME );
 }

 public function SwitchToNormalCamera()
 {
  cameraNormal.SetActive(true);
  cameraRed.SetActive(false);
  cameraBlue.SetActive(false);
  cameraOrange.SetActive(false);
 }


 function Awake()
 {
  if ( Instance != null )
  {
   Destroy (this );
  }
  else
  {
   Instance = this;
  }

 }

 function Start ()
 {
  SwitchToNormalCamera();
 }

}

PickUp fruit - initiate effect code


#pragma strict
public enum ColorFilterType { normal, red, blue, orange };
public var colorSwitcher : ColorFilterType;
function OnTriggerEnter (other : Collider)
{
 renderer.enabled = false;

 switch ( colorSwitcher )
 {
  case ColorFilterType.normal:
 
   ColorFilterControl.Instance.SwitchToNormalCamera();
   break;
  
  case ColorFilterType.red:
 
   ColorFilterControl.Instance.SwitchToRedCamera();
   break;
  case ColorFilterType.blue:
 
   ColorFilterControl.Instance.SwitchToBlueCamera();
   break;
  
  case ColorFilterType.orange:
 
   ColorFilterControl.Instance.SwitchToOrangeCamera();
   break;  
 }
 
 yield WaitForSeconds (8);
 renderer.enabled = true;
}
/*function update();
{
 if (renderer.enabled = false)
*/

Sound

sound is on the way, collected the set we agreed on, however, a small problem. (dont owrry its not going to stop is uts just a basic one) the audeo files are in diforent formats, like IFF and so on, however i also need to know what type of audeo file Unity uses so that i dont wait stime converting the audeo files to like MP3 or something and all of a sudden being told we need IFF or something like that.

in a nutshell, there ready, just need to know what they need to be converted too.

Monday, 29 April 2013

Beacon pickup / rotate code

using UnityEngine;
using System.Collections;
public class Pickup : MonoBehaviour {
 // Use this for initialization
 void Start () {

 }

 public float rotationSpeed = 100.0f;
 // Update is called once per frame
 void Update () {
 transform.Rotate(new Vector3 (0,rotationSpeed * Time.deltaTime, 0));
 }

 void OnTriggerEnter(Collider col){
 if(col.gameObject.tag == "Player"){
   col.gameObject.SendMessage("CellPickup");
   Destroy(gameObject);
  }
}
}