Tuesday, December 14, 2010
Week 11: Programming
Beginning Sedja AI Script:
var horous: GameObject;
var enemyState = "String";
var health=100;
var attackState="String";
function Start(){
enemyState="chasemode";
attackState="weak";
}
function Update () {
var dist =Vector3.Distance(horous.transform.position, transform.position);
if(dist>=5){
enemyState="chasemode";
}
if(enemyState=="chasemode"){
enemychase();
}
if(enemyState=="attackmode"){
attackmode();
}
if(health<=0){
Destroy(gameObject);
}
}
function enemychase(){
transform.LookAt(horous.transform);
var dist =Vector3.Distance(horous.transform.position, transform.position);
if(dist<=2.3){
enemyState="attackmode";
animation.Play ("runoutro");
}
else{
rigidbody.transform.Translate(5*Vector3.forward * Time.deltaTime);
animation.Play ("run");
}
}
function attackmode(){
if(health<=0){
animation.Play ("attack2");
}
else{
animation.Play ("attack");
}
}
function OnGUI () {
GUI.Label(Rect(Screen.width - 120, 10, 200, 50),"Enemy Health: " + health);
}
function OnTriggerExit(other : Collider){
if (other.gameObject.tag == "player_weapon") {
health-=10;
}
}
Week 6: Programming
var health= 100;
function OnGUI () {
GUI.Label(Rect(Screen.width - 100, 10, 200, 50),"Enemy Health: " + health);
}
function OnGUI () {
GUI.Label(Rect(Screen.width - 100, 10, 200, 50),"Enemy Health: " + health);
}
Monday, December 6, 2010
Week 9: Programming: Enemy AI
var enemyaggro : GameObject;
var player2 : GameObject;
var enemyState = "String";
var health= 100;
var localChase =false;
var firstX=Vector3(0.0, 0.0, 0.0);
var lastPositionPlayer= Vector3(0.0, 0.0, 0.0);
var returnTimer=0.0;
var lookingTimer=0.0;
var enemyPrefab : GameObject;
function Start(){
enemyState = "idle";
print(enemyState);
firstX=transform.position;
}
function Update () {
if(enemyState=="idle"){
returnTimer=0.0;
}
if(enemyState == "chase"){
enemychase();
print(enemyState);
}
if(enemyState == "attackmode"){
enemyAttack();
print(enemyState);
}
if(localChase){
enemyState="chase";
}
if(enemyState=="looking"){
startLooking2();
}
if(enemyState=="confusion"){
startConfusion();
}
if(enemyState=="return"){
returnPosition();
}
if(returnTimer>=5){
enemyState="stuck";
stuck();
returnTimer=0.0;
}
if(lookingTimer>=20){
enemyState="return";
lookingTimer=0.0;
}
}
function OnCollisionStay (collision : Collision) {
if (collision.gameObject.tag == "Player") {
enemyState="attackmode";
}
}
function enemyAttack(){
transform.LookAt(player2.transform);
localChase=false;
yield;
print("enemyhit");
yield;
localChase=true;
enemyState="idle";
}
function enemychase(){
transform.LookAt(player2.transform);
var dist =Vector3.Distance(player2.transform.position, transform.position);
if(dist<=2){
localChase=false;
enemyState="attackmode";
}
else{
rigidbody.transform.Translate(2*Vector3.forward * Time.deltaTime);
}
}
function startLocalChase () {
localChase =true;
}
function startLooking(){
localChase = false;
lastPositionPlayer=player2.transform.position;
enemyState ="looking";
transform.LookAt(lastPositionPlayer);
}
function startLooking2(){
if(!localChase){
lookingTimer+= Time.deltaTime;
transform.LookAt(lastPositionPlayer);
rigidbody.transform.Translate(2*Vector3.forward * Time.deltaTime);
var dist =Vector3.Distance(lastPositionPlayer, transform.position);
if(dist<=2){
enemyState="confusion";
print(enemyState);
}
}
}
function startConfusion(){
if(!localChase){
lookingTimer=0.0;
transform.Rotate(20*Vector3.down * Time.deltaTime);
yield WaitForSeconds(2);
enemyState="return";
print(enemyState);
}
}
function returnPosition(){
if(!localChase){
returnTimer+= Time.deltaTime;
transform.LookAt(firstX);
rigidbody.transform.Translate(2*Vector3.forward * Time.deltaTime);
var dist =Vector3.Distance(firstX, transform.position);
if(dist<=2){
enemyState="idle";
print(enemyState);
}
}
}
function stuck(){
print(enemyState);
yield WaitForSeconds(2);
enemyState="idle";
enemyarggo = Instantiate(enemyPrefab, firstX, transform.rotation);
Destroy(gameObject);
}
function OnGUI () {
GUI.Label(Rect(Screen.width - 120, 10, 200, 50),"Enemy Health: " + health);
}
var player2 : GameObject;
var enemyState = "String";
var health= 100;
var localChase =false;
var firstX=Vector3(0.0, 0.0, 0.0);
var lastPositionPlayer= Vector3(0.0, 0.0, 0.0);
var returnTimer=0.0;
var lookingTimer=0.0;
var enemyPrefab : GameObject;
function Start(){
enemyState = "idle";
print(enemyState);
firstX=transform.position;
}
function Update () {
if(enemyState=="idle"){
returnTimer=0.0;
}
if(enemyState == "chase"){
enemychase();
print(enemyState);
}
if(enemyState == "attackmode"){
enemyAttack();
print(enemyState);
}
if(localChase){
enemyState="chase";
}
if(enemyState=="looking"){
startLooking2();
}
if(enemyState=="confusion"){
startConfusion();
}
if(enemyState=="return"){
returnPosition();
}
if(returnTimer>=5){
enemyState="stuck";
stuck();
returnTimer=0.0;
}
if(lookingTimer>=20){
enemyState="return";
lookingTimer=0.0;
}
}
function OnCollisionStay (collision : Collision) {
if (collision.gameObject.tag == "Player") {
enemyState="attackmode";
}
}
function enemyAttack(){
transform.LookAt(player2.transform);
localChase=false;
yield;
print("enemyhit");
yield;
localChase=true;
enemyState="idle";
}
function enemychase(){
transform.LookAt(player2.transform);
var dist =Vector3.Distance(player2.transform.position, transform.position);
if(dist<=2){
localChase=false;
enemyState="attackmode";
}
else{
rigidbody.transform.Translate(2*Vector3.forward * Time.deltaTime);
}
}
function startLocalChase () {
localChase =true;
}
function startLooking(){
localChase = false;
lastPositionPlayer=player2.transform.position;
enemyState ="looking";
transform.LookAt(lastPositionPlayer);
}
function startLooking2(){
if(!localChase){
lookingTimer+= Time.deltaTime;
transform.LookAt(lastPositionPlayer);
rigidbody.transform.Translate(2*Vector3.forward * Time.deltaTime);
var dist =Vector3.Distance(lastPositionPlayer, transform.position);
if(dist<=2){
enemyState="confusion";
print(enemyState);
}
}
}
function startConfusion(){
if(!localChase){
lookingTimer=0.0;
transform.Rotate(20*Vector3.down * Time.deltaTime);
yield WaitForSeconds(2);
enemyState="return";
print(enemyState);
}
}
function returnPosition(){
if(!localChase){
returnTimer+= Time.deltaTime;
transform.LookAt(firstX);
rigidbody.transform.Translate(2*Vector3.forward * Time.deltaTime);
var dist =Vector3.Distance(firstX, transform.position);
if(dist<=2){
enemyState="idle";
print(enemyState);
}
}
}
function stuck(){
print(enemyState);
yield WaitForSeconds(2);
enemyState="idle";
enemyarggo = Instantiate(enemyPrefab, firstX, transform.rotation);
Destroy(gameObject);
}
function OnGUI () {
GUI.Label(Rect(Screen.width - 120, 10, 200, 50),"Enemy Health: " + health);
}
Tuesday, November 23, 2010
Friday, November 19, 2010
Wednesday, November 10, 2010
Week 5: Programming: AI
var enemyaggro : GameObject;
var player2 : GameObject;
var enemyState = "String";
var health= 100;
var localchase =false;
var playerLastX=0.0;
var playerLastZ=0.0;
var playerLastY=0.0;
var firstX=0.0;
var switcher=1;
function Start(){
enemyState = "idle";
print(enemyState);
firstX=transform.position.x;
}
function Update () {
if(enemyState == "chase"){
enemychase();
print(enemyState);
}
if(enemyState == "attackmode"){
enemyAttack();
print(enemyState);
}
if(localchase){
enemyState="chase";
}
if(enemyState=="looking"){
startLooking2();
}
if(enemyState=="confusion"){
startConfusion();
}
}
function OnCollisionStay (collision : Collision) {
if (collision.gameObject.tag == "Player") {
enemyState="attackmode";
}
}
function enemyAttack(){
transform.LookAt(player2.transform);
print("enemyhit");
yield WaitForSeconds(3);
enemyState="idle";
}
function enemychase(){
transform.LookAt(player2.transform);
rigidbody.transform.Translate(2*Vector3.forward * Time.deltaTime);
}
function startLocalChase () {
localchase =true;
}
function startLooking(){
localchase = false;
playerLastX=player2.transform.position.x;
playerLastZ=player2.transform.position.z;
playerLastY=player2.transform.position.y;
enemyState ="looking";
transform.LookAt(Vector3(playerLastX,playerLastY,playerLastZ));
}
function startLooking2(){
if(!localchase){
rigidbody.transform.Translate(2*Vector3.forward * Time.deltaTime);
yield WaitForSeconds(6);
enemyState="confusion";
print(enemyState);
}
}
function startConfusion(){
if(!localchase){
transform.Rotate(20*Vector3.down * Time.deltaTime);
}
}
function OnGUI () {
GUI.Label(Rect(Screen.width - 120, 10, 200, 50),"Enemy Health: " + health);
}
Tuesday, October 26, 2010
Week 4: Programming
function Update() {
if(Input.GetButtonDown("KeyBoardAttack(F)"))
{
swordenable();
}
}
function swordenable(){
gameObject.tag = "player_weapon";
print("namechanged");
yield WaitForSeconds(1);
gameObject.tag = "Untagged";
}
Code which solves the previous weeks problem. Now the dagger is only active for one second after you hit the attack button.
if(Input.GetButtonDown("KeyBoardAttack(F)"))
{
swordenable();
}
}
function swordenable(){
gameObject.tag = "player_weapon";
print("namechanged");
yield WaitForSeconds(1);
gameObject.tag = "Untagged";
}
Code which solves the previous weeks problem. Now the dagger is only active for one second after you hit the attack button.
Week 3: Programming
function OnTriggerEnter(other: Collider)
{
if(other.gameObject.tag == "player_weapon")
{
print("hit");
SendMessageUpwards ("Assasination");
}
}
This code is on a collider behind the enemy and when you sneak up behind him and attack him he will die in one hit. A problem that I am having is that the sword object is always active. So even without hitting the attack button it will kill then enemy. One way to solve this problem is im am going to change the name of the collider for the sword and only change it when the attack button is pressed and then change it back in a couple of seconds.
{
if(other.gameObject.tag == "player_weapon")
{
print("hit");
SendMessageUpwards ("Assasination");
}
}
This code is on a collider behind the enemy and when you sneak up behind him and attack him he will die in one hit. A problem that I am having is that the sword object is always active. So even without hitting the attack button it will kill then enemy. One way to solve this problem is im am going to change the name of the collider for the sword and only change it when the attack button is pressed and then change it back in a couple of seconds.
Tuesday, October 12, 2010
Week 2: Programming
Week 2: Level Design
Tuesday, September 21, 2010
Tuesday, September 14, 2010
Animation: Claw attack reference
I couldnt find any good reference on an claw attack so I did my own
Tuesday, August 31, 2010
Programming: Test Enviornment 03: One shadow collider
Light map created for unity
UVoutline of level 3
Overview shot in unity of the shadow collider in the scene, scene is lit with no lights
Mesh for shadow collider, this collider is ignored in unity and is used as a mesh collider. This is now used for the shadows instead of creating a ton of colliders I have one collider now.
Level 3 before modifications
Tuesday, August 24, 2010
Animation: Character Idle
I only animated the arm I need to animate the head and bring the elbow up a little more also the entire body as well needs to be animated
Monday, August 23, 2010
Programming: Test Enviornment 03: Enemy Collider/Move Script
Tuesday, August 17, 2010
Saturday, August 14, 2010
Test Level Enviorment 03: Shader Script
Heres a script we can use so our char is trans/shadowing everytime hes in the shadows and when he is in the light is alpha is 100%
Heres a script where the enemies detect you in the light but not in the shadows
Tuesday, August 10, 2010
Subscribe to:
Posts (Atom)