It's kinda a long tutorial. since it explain everything with details to help understand the whole process.
I'm currently at the step of C# coding. Although basicly its only copy and paste the code written in the tutorial to the file in the game engine. But I do have some questions abot the C# coding.
oreo, if you know the answer and don't mind sharing, could your post it here? so anybody interested could get some help from it.
Code:
using UnityEngine;
using System.Collections;
public class zombieAnimator : MonoBehaviour {
private SpriteRenderer spriteRenderer;
public Sprite[] sprites;
public float framesPerSecond;
// Use this for initialization
void Start () {
spriteRenderer = renderer as SpriteRenderer;
}
// Update is called once per frame
void Update () {
int index = (int)(Time.timeSinceLevelLoad * framesPerSecond);
index = index % sprites.Length;
spriteRenderer.sprite = sprites[ index ];
}
}
question 1: is the code suppose to look like above after typing everything in? I'm not sure the position of the two public variable declaration.
question 2: is SpriteRenderer and Sprite[] consider as variable type (same as float) in C# language, since I never see other language using those type to do variable declaration.
question 3: I'm feeling confused by the sentence "spriteRenderer = renderer as SpriteRenderer; " what does this statement do?
The zombie do start to do moving animation after input those code into unity. It's today's progress so far. I'll finish rest of the tutorial tomorrow. If I find more questions, I'll post it here.