Hi Guys, I am Karthik and I am a new person to the game industry and presently I am following one of the tutorial which i was found on the internet. Using that tutorial I am trying to develop a game by using unity 3D and When i was tried to execute the code it shows me ';' this character is missing, -->void HandleAnimation() // in this place { FindAnimation (); ProcessAnimation (); } -->void FindAnimation() // in this place also
The whole code is given below. Please have a loot at this and give me a solution. Looking for your reply guys.
using UnityEngine; using System.Collections; public class AIscript : MonoBehaviour { //game objects (variables whjich point to game objects) private GameObject objPlayer; private GameObject objCamera;
//input variables (variables used to process and handle input)
private Vector3 inputRotation;
private Vector3 inputMovement;
//identify variables (variables specific to the game object)
public float moveSpeed = 100f;
private bool thisIsPlayer;
//calculation variables (varibles used for calculation)
private Vector3 tempVector;
private Vector3 tempVector2;
private int i;
// animation variables (varibales used for processing animation)
public float animationFrameRate = 11f; //how many frames to play per second
public float walkAnimationMin = 1; //the first frame of the walk animation
public float walkAnimationMax = 10; //the lasr frame of the walk animation
public float standAnimationMin = 11; //the first frame of the stand animation
public float standAnimationMax = 20; //the last frame of the stand animation
public float meleeAnimationMin = 22; // the first frame of the melee animation
public float meleeAnimationMax = 30; // the last frame of the melee animation
public float spriteSheetTotalRow = 5; //the totzl number of the column sprite sheet
public float spriteSheetTotalHigh = 4; //the total number of the rows of the sprite sheet
private float frameNumber = 1; // the current frame being framed
private float animationStand = 0; //the ID of the stand animation
private float animationWalk = 1; //the ID of the walk animation
private float animationMelee = 2; //the ID of the melee animation
private float currentAnimation = 1; //the ID of the current animation being played
private float animationTime = of; //time to pass beofre playing the next generation
private vector2 spriteSheetCount; //the x,y postion of the frame
private vector2 spriteSheetOffset; //the offset value of the x,y coordiante for the texture
public vector2 spriteSheetOriginOffset;
// Use this is for initialization
void start () {
objPlayer = (GameObject) GameObject.FindWithTag ("Player");
objCamera = (GameObject) GameObject.FindWithTag ("MainCamera");
if (gameObject.tag == "Player") { thisIsPlayer = true; }
}
// Update is called once per frame
void Update () {
FindInput ();
ProcessMovement ();
HandleAnimation ();
if (thisIsPlayer == true)
{
HandleCamera ();
-->**void HandleAnimation()** // handles all animation
{
FindAnimation ();
ProcessAnimation ();
}
-->**void FindAnimation()**
{
if (inputMovement.magnitude > 0)
{
currentAnimation = animationWalk;
} else {
currentAnimation = animationStand;
}
}
void ProcessAnimation ()
{
animationTime -= Time.deltaTime; // animationTime -= Time.deltaTime; subtract the number of seconds passed since the last frame, if the game is running at 30 frames per second the variable will subtract by 0.33 of a second (1/30)
if (animationTime <= 0)
{
frameNumber +=1; //one play animations (play from start to finish)
if (currentAnimation == animationMelee)
{
frameNumber = Mathf.Clamp(frameNumber,meleeAnimationMin,meleeAnimationMax+1);
if (frameNumber > meleeAnimationMax )
{
/* if (meleeAttackState == true) // this has been commented out until we add enemies that will attack with their evil alien claws
{
frameNumber = melleAnimationMin;
}
else
{
currentFrame = frameStand;
frameNumber = standAnimationMin; */
} // cyclic animations ( cycle through the animation)
if (currentAnimation == animationStand)
{
frameNumber = Mathf.Clamp(frameNumber,standAnimationMin,standAnimationMax+1);
if (frameNumber > standAnimationMax)
{
frameNumber = standAnimationMin;
}
}
if (currentAnimation == animationWalk)
{
frameNumber = Mathf.Clamp(frameNumber,walkAnimationMin,walkAnimationMax+1);
if (frameNumber > walkAnimation)
{
frameNumber = walkAnimationMin;
}
}
animationTime += (1/animationFrameRate); // if the animation FrameRate is 11, 1/11 is one elventh of a second , that is the where we waiting before we play the next frame.
}
spriteSheetCount.y = 0;
for (i=(int) frameNumber; i > 5; i-=5) // find the number of frames down the animation is and set the y coordinate accordingly
{
spriteSheetCount.y +=1;
}
spriteSheetCount.x = i - 1; // find the x coordinate of the frame to play
spriteSheetOffset = new Vector2(1 - (spriteSheetCount.x/spriteSheetTotyalRow), 1 - (spriteSheetCount.y/spriteSheetTotalHigh)); //find the x and y coordinate of the frame to display
spriteSheetOffset += spriteSheetOriginOffset;
yourGameObjectVariable.renderer.materail.SetTextureOffset ("_MainText", spriteSheetOffset); // offset the texture to display the correct frame
}
}
}
}
}
void FindInput ()
{
if (thisIsPlayer == true)
{
FindPlayerInput ();
} else {
FindAIinput ();
}
}
void FindPlayerInput ()
{
//find vector to move
inputMovement = new Vector3 ( Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical") );
// find vector to the mouse
tempVector2 = new Vector3(Screen.width * 0.5f,0,Screen.height * 0.5f);
// the position of the middle of the screen
tempVector = Input.mousePosition;
// find the position of the mouse on screen
tempVector.z = tempVector.y;
// input mouse position gives us 2D coordiantes, I am moving Y coordiante to the Z coordiante in temp Vector and setting the Y coordinate to 0, so that the vetor will read the input along the X (left and right side of the screen) and Z (up and down of the screen) axis, and not the X and Y (in and out of the screen) axis
tempVector.y = 0;
Debug.Log(tempVector);
inputRotation = tempVector - tempVector2;
// the direction we want face/aim/shoot/ is from the middle of the screen to where the mouse is pointing
}
void FindAIinput ()
{
}
void ProcessMovement ()
{
rigidbody.AddForce (inputMovement.normalized * moveSpeed * Time.deltaTime);
transform.rotation = Quaternion.LookRotation (inputRotation);
transform.eulerAngles = new Vector3 (0, transform.eulerAngles.y + 180, 0);
transform.position = new Vector3 (transform.position.x,0,transform.position.z);
}
void HandleCamera ()
{
objCamera.transform.position = new Vector3 (transform.position.x,15,transform.position.z);
objCamera.transform.eulerAngles = new Vector3 (90,0,0);
}
}