Friday, 15 March 2013

Shelf Door Code

var ShelfDoor:GameObject;
var isOpen;

function OnMouseDown()
{

      if(!this.isOpen){
      ShelfDoor.animation.Play("ShelfDoorOpen");
      this.isOpen = true;
}
else
{

       ShelfDoor.animation.Play("ShelfDoorClose");
       this.isOpen = false;

   }
}

This is the code Alistair and I have used to get the shelf doors to open on one click, and close on another click.

Bush generator

Found a way to generate plants using script in Maya called Bush Generator. Creates some good results quickly and can also generate wind animations. I'm having problems with getting the plants to generate with textures on though and there isn't much online help with this package.
I may have to texture them by hand though this wouldn't be ideal if its possible to automatically have the whole model textured while being generated.

Also unsure whether its feasable to use this as leaves could be shown as just textures on a plane which would drastically reduce poly count. The furthest plant on the grid is 14000 verts in total but 4000 verts without leaves.

My plan was to use this for general foliage in the game which wouldn't have any fruit and would just be scenery as we need to space out the plants with fruit and if we do this we'll need plants without fruit to balance out the environment.

I'm currently thinking maybe I should use this to generate stems and then add leaves via textures?

Thursday, 14 March 2013

Player Control Script

using UnityEngine;using System.Collections;

public class PlayerControl : MonoBehaviour
{

public GUIText tmMessage;

public GameObject RespawnManager;
public void Died()

{

tmMessage.text = "You have died, respawning...";
 
 //disable first person controller script

gameObject.SendMessage ("SetControllable", false);
//call the cleanup method after 5seconds

Invoke ("CleanUp", 5F); 
}
private void CleanUp()

{

tmMessage.text = "";


//Enable first person controller script

gameObject.SendMessage ("SetControllable", true); 
 //Respawn the player

RespawnManager.SendMessage("RespawnPlayer"); 
}


// Use this for initialization

void Start ()

{

CleanUp();

}


// Update is called once per frame

void Update () {

 
}

}

Here is the other lot of script for the respawn point script.

Respawn Point Script

using UnityEngine;using System.Collections;

public class RespawnManager : MonoBehaviour{

public GameObject[] RespawnPoints;

public GameObject player;


public bool enableRespawnTimer;



// Use this for initialization

void Start ()

{
//InvokeRepeating ("RespawnPlayer", 0, 5F);

}


public void RespawnPlayer ()

{
int randomIndex = Random.Range (0, RespawnPoints.Length);

player.transform.position = RespawnPoints[randomIndex].transform.position;

}



void RespawnPlayerRepeatedly ()

{
if ( enableRespawnTimer )

{
int randomIndex = Random.Range (0, RespawnPoints.Length);

player.transform.position = RespawnPoints[randomIndex].transform.position;

}

else

{

CancelInvoke();

}

}

// Update is called once per frame

void Update ()
{

if (enableRespawnTimer && !IsInvoking ("RespawnPlayer") )

{

InvokeRepeating ("RespawnPlayer", 0, 5F);
 
}

}

}

We could use this code so that if the player dies, they could respawn at the pod and start the game again. With this, you also need to add some code to the PlayerController script, which I wil be posting after this.


Tuesday, 12 March 2013

Unity & House Pod Update ( 3D Work )

House Pod

Below is the main bace for the main charicter his or her House pob these are self contaned houses, that are complete with a Shower, Toliet, Sinks, Kitchen Dining Area, Beds, TV and lots of storage. House Pod is made to be condecned with as little space as possable to save on fual and to get as many people on the ship as possalbe. As you can see below there is an inside iamge and an outside image to show you what it will look like.

Things I Need To Do:
  • Make sure textures work in unity
  • Make sure eveything is UV map
  • Add normal maps to appropriate textures
Problems:
  • After the import into unity as you can see blow from the third image some of the textures had flipped and specular map are reflecting from the wrong angle



Unity Terrain

Below is some screen shorts of the unity terrain with textures that were made by toop, these includ normal maps to add realism and shad. I have been adding in the plant & tree modles that the other members of the group have made, I had some trouble with importing the modles and adding them to the terrain painting tool for trees and making the normal maps show in the game as well by haveing to add a material to the lighting to get it to work.

Things I Need To Do:
  • add a Nature/Soft Occlusion shader to some of the models to make shadows
  • add more texture toop will be making
Problems
  • trying to get a plant that is painted on the water i had to make an invsable terrain and paint the plants on top of it as you can see below this worked
  • importing the modles and adding them to the terrain painting tool for trees bcecause of it not having a valided mesh render: But i found out the i had to delet all the history in maya and combine it into a single mesh for this to work and add an Nature/Soft Occlusion shader to get shadows




Monday, 11 March 2013

Monday 11th March Group Discussion

Okay here is the down-low

For the end of this week -

Alistair -
Finish off the texturing on the pod, and finish the terrain adding in the 3D assets that everyone else will have done, plants mainly. and using Toop's textures for the terrain.


Alice -
If you can work on getting the health control scriptand death spots working, we want deathspots preferably where ever the methane trees are so a small sphere radius?
Also for the health control we are thinking decrease health by one every 120 seconds I think its should work you just need to literally change the seconds in the script and the decrease health from i think it was 5? to 1 ? if theres any problems though I'll help out and brainstorm


Cat - I'm going to be using the unity book and hopefully ill get fixing the door animation and adding javascript code to it to make it open so its using a onMouseDown function also I will be adding the pick up code on to the plants using what we did last year with tanguy.

Jamie - Work on with the A.I.  as far as i know you just need to texture and rig it , comment to me are you going to use C.A.T?

Toop - from talking with alistair can you comment what textures if any that you need to get done ?
Grass textures amd rock textures ?


Also everyone please get your plants finish if not already and add concept images for them >.< pwease?

Door Script

Tanguy helped me out this morning with coding for the door, as the code we are using in C# is not working properly (even though we don't have any errors). Tanguy showed me how to have a door open when you click on it in Javascript.

function OnMouseDown() {
      animation.Play("DoorOpen");
}

All we need to do is animate the doors opening and closing. We tested this code out on a quick scene with a cube as a door and it works.

HealthControl Script

using UnityEngine;using System.Collections;

public class HealthControl : MonoBehaviour
{   public TextMesh tmPlayerHealth; 

   public int playerHealth = 0;
   private float updateDisplayTime = 0F;
 
// Use this for initialization
void Start ()
 {
 
   playerHealth = 100;
   DisplayHealth();
 updateDisplayTime = Time.time + 5F;

}
void OnDisable()

{

   Destroy( gameObject );

}
// Update is called once per frame
void Update ()
{
   if ( updateDisplayTime < Time.time )
   {

        playerHealth -= 10;

        DisplayHealth();

        updateDisplayTime = Time.time + 5F;

   }
   if ( playerHealth <= 0 )
   {
       this.enabled = false;
   }


}
void OnControllerColliderHit( ControllerColliderHit collisionObj )

{   if ( collisionObj.gameObject.tag == "Enemy" )
   {

        playerHealth--;

        DisplayHealth();

   }



        Debug.Log ("OnControllerColliderHit detected with tag "+collisionObj.gameObject.tag);
 
} // This method is not called when using a CharacterController object
// Use OnControllerColliderHit() method instead

void OnCollisionEnter( Collision collisionObj )
{
    if ( collisionObj.gameObject.tag == "Enemy" )
    {

         playerHealth--;

         DisplayHealth();
    }


Debug.Log (
"OnCollisionEnter detected with tag "+collisionObj.gameObject.tag);

}void OnTriggerStay( Collider colliderObj )
{
    if ( colliderObj.gameObject.tag == "Friend" )
    {

        playerHealth++;

        DisplayHealth();

    }

}
void DisplayHealth()

  {

     tmPlayerHealth.text = playerHealth.ToString();

  }

}


This is the script to control the health when you enter the methane field.

DeathSpot Script

using UnityEngine;using System.Collections; 
public class DeathSpot : MonoBehaviour {
{

    void OnTriggerEnter( Collider hitObj )
      {
       
if ( hitObj.tag == "Player" )

        {

          hitObj.gameObject.BroadcastMessage("Died");


        }


      }

// Use this for initialization

void Start () {

}


// Update is called once per frame

void Update () {



   }

}



This is the script we hope to use for our Methane Field. When the player enters the 'deathspot'/ methane field, their health will depleat.