Pages

Saturday 23 June 2012

24/6/2012

 The stuff I need to change are the Targeting script for the player and Animation walk and slash for the player.

 More Updates on what I've done for the game.
As for the dummies I manage to remodel it and do some research on making the AI track the Player So here's a piece of the tracking script which I did.
_________________________________________________________________________________

using UnityEngine;
using System.Collections;

public class EnemyAI : MonoBehaviour {
public Transform target;
public int moveSpeed;
public int rotationSpeed;
public int maxDistance;

private Transform myTransform;

void Awake() {
myTransform = transform;
}

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

target = go.transform;

maxDistance = 2;
}

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

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

if(Vector3.Distance(target.position, myTransform.position) > maxDistance) {
//move towards target
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
}
}
_________________________________________________________________________________

So basically i get the idea that the  dummy is trying to find the transform position of the player and also target the Game object with the tag name player on it, then it will approach it. I saw some of the tutorials on YouTube and did the rest of the scripts myself which are the timer, enemy attack, enemy health, player attack, player health,Score, Spawn and etc.

I manage to create a spawn points for the dummy to spawn every 10 seconds and target the player directly. I did the timer script and given the player exactly 2 mins to kill as much dummies as possible before game over.

As for the dummy, I redo the dummy to make it more human-like rather than the old one which is like a t-pose and I find the dummy hard to move against each other with the t-pose.

BEFORE


AFTER


The start menu and how to play was done by me, to show some instruction on how to play the game before actually playing it.
Here are the pictures of it.


The only problem which we are having now is that after we killed the dummy, we wanna target other dummy there's an error saying. MissingReferenceException: The object of type "transform" has been destroyed but you are still trying to access it.

No comments:

Post a Comment