MiOopinion.com

where we speak freely
It is currently Thu Mar 28, 2024 3:47 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: great unity tutorial
PostPosted: Wed Apr 16, 2014 12:05 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 02, 2014 4:09 pm
Posts: 285
Oreo find a great Unity game dev software tutorial. I'm sharing his link here. The tutorial is easy to follow and can help your get a brief idea how to do simple game design with Unity engine (basic version is free btw).
If anybody interested in developing their own games or app, could take a look at this tutorial to get started.
http://www.raywenderlich.com/61532/unit ... ng-started

_________________
Image


Top
 Profile  
 
 Post subject: Re: great unity tutorial
PostPosted: Wed Apr 16, 2014 12:50 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 02, 2014 4:09 pm
Posts: 285
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.

_________________
Image


Top
 Profile  
 
 Post subject: Re: great unity tutorial
PostPosted: Wed Apr 16, 2014 1:43 pm 
Offline
Site Admin

Joined: Fri Jan 03, 2014 10:50 pm
Posts: 5
kittykuma wrote:
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.


I'm no expert in C# but here's the answers to your questions.

1) Yea the code looks fine
2) SpriteRenderer and Sprite are Classes. spriteRenderer is an object of class SpriteRenderer, and sprite is a pointer for a an array of type Sprite.
3) That statement casts the variable renderer as a SpriteRenderer object. It has to do with setting the sprite texture.

Here's some useful links:
http://unity3d.com/learn/documentation
http://docs.unity3d.com/Documentation/Manual/index.html
http://docs.unity3d.com/Documentation/C ... index.html

Let me know if you have any other questions.


Top
 Profile  
 
 Post subject: Re: great unity tutorial
PostPosted: Wed Apr 16, 2014 10:53 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 02, 2014 4:09 pm
Posts: 285
thanks for posting answers to my questions.
I finished the tutorial. zombie now can move along the mouse's cursor. pretty cool.
I do encounter some problem while follow the tutorial.
The unity file keep reloading the previous state when editing the script file in MonoDevelop.
for example I remember that I already populated the Zombie's sprite array yesterday. Today after I do some editing in the ZombieAnimator.cs file, the unity's Zombie's sprite array become empty :o
I did save scene in unity yesterday.
I wonder what cause the file state reloading previous save state.
Do you encounter similar problems oreo?

_________________
Image


Top
 Profile  
 
 Post subject: Re: great unity tutorial
PostPosted: Thu Apr 17, 2014 1:36 pm 
Offline
Site Admin

Joined: Fri Jan 03, 2014 10:50 pm
Posts: 5
kittykuma wrote:
thanks for posting answers to my questions.
I finished the tutorial. zombie now can move along the mouse's cursor. pretty cool.
I do encounter some problem while follow the tutorial.
The unity file keep reloading the previous state when editing the script file in MonoDevelop.
for example I remember that I already populated the Zombie's sprite array yesterday. Today after I do some editing in the ZombieAnimator.cs file, the unity's Zombie's sprite array become empty :o
I did save scene in unity yesterday.
I wonder what cause the file state reloading previous save state.
Do you encounter similar problems oreo?


When making edits to files/settings, make sure the game isn't running first. If you make changes when the game is running, it will all be undone if you stop the game. It's only temporary changes. If you want to make permanent changes, edit the files when the game is not running.


Top
 Profile  
 
 Post subject: Re: great unity tutorial
PostPosted: Thu Apr 17, 2014 2:14 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 02, 2014 4:09 pm
Posts: 285
oreo wrote:
When making edits to files/settings, make sure the game isn't running first. If you make changes when the game is running, it will all be undone if you stop the game. It's only temporary changes. If you want to make permanent changes, edit the files when the game is not running.


Great tips! Again you pin point the problem so quickly. You are the best. Thanks! :mrgreen:

_________________
Image


Top
 Profile  
 
 Post subject: Re: great unity tutorial
PostPosted: Thu Apr 17, 2014 2:22 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 02, 2014 4:09 pm
Posts: 285
What's the difference between save scene and save project in unity?

_________________
Image


Top
 Profile  
 
 Post subject: Re: great unity tutorial
PostPosted: Thu Apr 17, 2014 3:34 pm 
Offline
Site Admin

Joined: Fri Jan 03, 2014 10:50 pm
Posts: 5
kittykuma wrote:
What's the difference between save scene and save project in unity?


A scene is like a level. Saving a scene saves all the level settings. Saving the project saves all the assets and scenes included in your game.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group