Friday, December 28, 2012

Why am I lazy

Please have a full read on below article, it is really cool now I finally understand more about my brain

http://serendip.brynmawr.edu/bb/neuro/neuro05/web1/isiddiqui.html



my thought on dopamine

When you experience something good or awesome, your brain will release dopamine, and you will feel happy and you will want to repeat the same experience again and again

So what kind of activity will release dopamine?

1. food
2. sex
3. risk and reward

thats why gambling is such a big addiction

and why do human need to release dopamine when there is "risk and reward" this is due to human need to take risk to achieve something bigger

such as me wasting all my time and money to build stupid game and hoping can earn me some buck

so back to the question, why am I lazy

this is because the process of building the game take too long and the brain did not release enough dopamine to keep me motivated

so what should I do , go and buy some dopamine pill to swallow?

nah, I wont do that, maybe just ease up a bit until the dopamine juice is a bit more to get me going, thats the only strategy i can think of

totally no idea how to fix this

maybe there really are no way to fix this, just keep forcing yourself to finish the thing







Tuesday, December 25, 2012

GIMP how to increase the size of the image without scaling it

Let say you have a GIMP image of size 100,100

you want it to be 200,200 but you dont want to scale the original pic, you just want extra space for your image, here is how you should do it

1. ON TOP, under IMAGE->CANVAS SIZE
- set your size to 200,200

2. Right click on your image, LAYER TO IMAGE SIZE

Hope it help, it is very difficult for me, I am noob

Monday, December 17, 2012

Saturday, December 15, 2012

Unity OnGUI how to change color, transparency and font

Here is what I found after googling for a while

1. On your unity, ASSETS -> CREATE -> GUISKIN, name it "myGUISKIN"
2. On your script, create a new variable

var myskin : GUISkin ;


function OnGUI () 
{

    GUI.skin = myGUISkin;
}


3. Drag your script to one of the object, then drag your myGUISKIN into your script variable "myskin"
4. Now you can configure everything on your myGUISKIN, you can change the background color, you can change the font size and everything you can think of


Wednesday, December 12, 2012

Unity Function that return value

Here is how to return value for function in unity


function myFunction() : outputType {
    return variable;
}

Unity two dimension array


private var mystuff : int[,]=new int[52,3];


mystuff[12,12]=5;



Tuesday, December 11, 2012

Unity how to hide a single object

Here is what should do,

1. Open unity, create one object cube
2. Create new javascript then put


var mycube: Transform;

function update()
{

     mycube.transform.renderer.enabled=false;
}




3. drag this script into your cube object, 
4. drag the cube into your script variable "mycube"
5. if you run your app, the cube will be dissapear

Unity how to change text mesh when pushing button

Let say you want to change the value of text mesh by 10 everytime you pressing a button,

below is what you should do

1. Open Unity, add text mesh let say "myText"
2. Create a new javascript and attach it to your button
3. On your javascript put


private var myCredit : int=100;
private var myTextMesh :TextMesh

function awake()
{
      myTextMesh=transform.Find("myText").GetComponent(TextMesh);

}


function OnMouseDown()  //when pressing button
{
      myCredit += 10; 
      myTextMesh.text =myCredit.ToString();
}

Monday, December 10, 2012

Unity how you access other script

Let say you have 2 game object, Object A and Object B

Let say Object A have attached script A and Object B have attached script B

so how do you access script B function on your script A?

here is how you do it



ScriptA
var other : ScriptB;

function Update () {
    
    ScriptB.run();
}
ScriptB

function run() {
    Debug.Log("I RUN RUN RUN");
}







Note: MAKE SURE you drag OBJECT B into your OBJECT A script "Script A" variable "other"

Unity how to check which object you click using mouse

Here is what you should do if you wanna check which object you have clicked

function Update()
{
    //check if the left mouse has been pressed down this frame
    if (Input.GetMouseButtonDown(0))
    {
        //empty RaycastHit object which raycast puts the hit details into
        var hit : RaycastHit;
        //ray shooting out of the camera from where the mouse is
        var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, hit))
        {
            //print out the name if the raycast hits something
            Debug.Log(hit.collider.name);
        }
    }
}


Note: Make sure your object have box collider otherwise it wont be detected

Friday, December 7, 2012

Blender 2.6 how to delete uv map

Let say you already have a UV map and you dont want it anymore, here is what I do

1. in your blender, press "TAB" to go to edit mode
2. press "A" to select all
3. VIEW "UV MAP"
4. on the bottom bar, find your image, then SHIFT CLICK "X" on the panel to unlink it


Sunday, December 2, 2012

Unity Detect Collision script

So let say you want to have something happen if collision detected, this is how you do it

1. Create a new script let say "collide"
2. Open your script , put

Function OnCollisionEnter()
{
    Debug.log("Collision detected");
}


However, let say you only want to do something if it collide with specific item

Function OnCollisionEnter( haha : Collision)
{
      if (haha.gameobject.name == "player")
      {
                  Debug.log("Collision detected on the player");
      }
      else if(haha.gameobject.name == "ball")
      {
                  Debug.log("Collision detected on the ball");
      }

}


then you just drag your script to your object that you wanna detect collision

However, this only work on Cube with rigid body

What if, you want the collision detect on your character controller and maybe you want to push the cube or ball around with your main character?

then below is the script that you should create and attach it to your main character



// this script pushes all rigidbodies that the character touches
var pushPower = 2.0;
function OnControllerColliderHit (hit : ControllerColliderHit) {
    var body : Rigidbody = hit.collider.attachedRigidbody;
    // no rigidbody
    if (body == null || body.isKinematic)
        return;
        
    // We dont want to push objects below us
    if (hit.moveDirection.y < -0.3
        return;
    
    // Calculate push direction from move direction, 
    // we only push objects to the sides never up and down
    var pushDir : Vector3 = Vector3 (hit.moveDirection.x, 0, hit.moveDirection.z);

    // If you know how fast your character is trying to move,
    // then you can also multiply the push velocity by that.
    
    // Apply the push
    body.velocity = pushDir * pushPower;
    
    if(hit.gameObject.name == "mycube")
    {
    Debug.Log("pushing cube");
    }
    else if(hit.gameObject.name== "myball")
    {
        Debug.Log("pushing ball");
    }
}

now my character can push the ball and cube around as you can see in the video




Unity Penelope Camera Relative Controller Summary

So here is the Unity Penelope Camera Relative Controller Summary

1. Create an empty camera pivot, under it create camera offset, under it put your camera

-camera offset, set to position 0, 0.94, 0
-camera, set to position 0, 5, -12
-drag the rotationconstraint.js and followtransform.js into camera pivot


2. Put in your main character

-drag the character controller and camera relative control.js into your main character

3. Create an empty object name it Joystick, create two empty object under it, one as leftpad, one as rightpad

-drag the guitexture and joystick.js into your leftpad and rightpad

-set the empty joystick to location 0,0,0
-set the texture of guitexture to the button texture
-set the "leftpad" guitexture pixel in set to 30,30,100,100 (x,y, width,height)
-set the "rightpad" guitexture pixel in set to 30,355,100,100 (x,y, width,height)


Now that you have drag all the neccessary script into the object, make sure you drag all the object into the script variable

1. On the "Camera Pivot", make sure you drag your main character into followtransform.js "Target Transform", also your rotationconstraint.js put min = -15, max = 15

2. On the Main character, make sure you drag leftpad, rightpad, camera pivot, camera into the camerarelativecontrol.js variable


Saturday, December 1, 2012

Today Progress: Finally I am able to test my unity game on my iPhone

So after paying USD400 for the unity IOS license and USD100 for the iPhone developer license, fix here and there, finally I am able to test my unity games on my iPhone


Yeah, just 2 joystick one to move the character around, and one to rotate around the screen


Unity How to Shrink your app size

Well, just like others I want to test out an empty unity project to see how big it is once it is installed into my iPhone.

So here it goes

first attempt, build into IOS, open IOS project in Xcode, Build and run -> 60 MB

60 MB !!!!!!!!! HOLY SHIT, I GOT EMPTY UNITY PROJECT

after googling for an hour and test out this and that

below is the step

Step 1: On your Unity,  File -> Build Setting -> Player Setting, on the IOS tab(3rd one), Target Device -> set to iPHONE ONLY
Target Platform set to armv7

I repeat the step to push it into my iPhone and now it show -> 35 MB

HOLY MOLY !!!!!!


Step 2: On your Xcode, Product -> Edit Schema, on the left hand side "run" tab, then middle "Info" tab , change the build configuration to "release"

Now I repeat the step to push it into my iPhone now it show -> 22.7 MB


I read many tutorial all asking you to buy the USD1500 unity pro which will further shrink down your app to 15MB, sigh, I am very poor, but if I am rich a bit I might pay USD1500 to shrink that 7 MB


Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger

I got this error:

Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger

Seem like even the empty app without anything I will get this error,

So I tried to fix it
1. Restart Xcode
2. Restart Computer
3. Restart your iPhone


Then i get this error


Assertion: should not be reached at tramp-arm.c:724


Finally, it turn out to be causing by Unity iPhone Simulator -> Your Device

meaning, you just need to go to the Xcode, on top left, then change it to Unity iPhone -> Your Device

then you can see it run perfectly on your iPhone

I wonder why this is not mention anywhere on the tutorial







Simulate Unity Penelope using mouse control

Below is the forum thread i found, tested and working

http://forum.unity3d.com/threads/54800-Is-there-a-way-to-simulate-the-Touch-using-the-mouse



Unity Penelope things I don't understand

Well, I have downloaded the unity penelope sample into my unity

however there are many problem with this app that I don't understand

1. When i try to build the unity version into IOS, it just fail to run in IOS with zero error, it just quit within 1 second
2. When I download the penelope app from the appstore, it is working fine, when i check the size it eat, it only eat 16 MB, but when i build empty project it eat 64MB, where did the 50MB coming from
3. Dragging the camera controller script into my own character will only work in unity but not when i build it into the IOS

sigh, rough road again, I am stuck!!!!!! if there are any expert out there who can help, PLEASE HELP ME!!!!

Sunday, November 25, 2012

I Bought the IOS license for USD400

So I start to get a little bit boring just doing the unity thing and I want to test my little game on my iPhone so I just paid the USD400 to buy the IOS license and now i am trying very hard to follow the tutorial below

http://wiki.unity3d.com/index.php?title=IPhone_Getting_Started_with_the_UnityRemote


It is very very very hard indeed and hopefully I can get it done

after 5 minutes of following the instruction

it said

you need to pay $99 to enroll in iPhone Developer Program to use unity remote

oh my god

need more money

well, i guess since I already walk so far, I need to pay again

ok, after paying USD99 for the iPhone developer program

I need to setup the certificate, which is super hard for me, anyway, below is the video how to do it

http://www.youtube.com/watch?v=HlRI30F6-Ek

and after 2 hour of trial and error following the tutorial i finally able to see the unity game on my iPhone

but
.
.
.
.
.
..
.
.
.
.
.
.
.
.
.
.
IT IS SO BLURRY on my iPhone!!!!!!!!

and it appear it will always be like that meaning you still need to do a proper install

after USD500 gone and this is what i got....ahhhhh, just not what i expected







today progress: Character can now enter 3 different building

So I have created 3 building and the character can run into it


Friday, November 23, 2012

Today Progress: Changing cloth for my character

So this is the first attempt to change cloth for my character as in the video


As you can see, i try to make 3 button, shirt, pants, hair,

when i click shirt, i got 5 option to change the shirt

when i click pants, i got another 5 option to change the pants

for the noob that wondering how I accomplish this, below is the stuff that i used

1. OnGui function
- write a new script with OnGui function then add 3 button to the screen, then when pressing any of the button, show a new selectionGrid with 5 item , then you can drag 5 different texture into your selection grid
- when clicking the item on the grid, just change the texture of your character body
-below is sample code


GridValue = GUI.SelectionGrid(Rect(200,200,400,400),GridValue, ShirtGrids, 5); mySkinnedMeshRenderer.materials[8].mainTexture=ShirtGrids[GridValue];



2. Blender UV mapping
- when you create your character on blender, you need to create UV mapping for your character
- you need to mark Seem on your character manually, then select the body part to unwrap it
- you can then export you uvmapping to .png file and draw your shirt or pants on it

any question feel free to ask

Tuesday, November 20, 2012

Unity how to change texture for Skinned Mesh Renderer using script


Let say you have a character object that have 5 material on it, below is how you can change all the 5 material color using script

1. Create a new javascript 
2. Paste in below code

var mySkinnedMeshRenderer: SkinnedMeshRenderer;

var texture1: Texture;



function Start () {


 mySkinnedMeshRenderer.materials[0].mainTexture=texture1;
 mySkinnedMeshRenderer.materials[1].mainTexture=texture1;
 mySkinnedMeshRenderer.materials[2].mainTexture=texture1;
 mySkinnedMeshRenderer.materials[3].mainTexture=texture1;
 mySkinnedMeshRenderer.materials[4].mainTexture=texture1;

}

3. Drag your code into your Character object
4. Click your Character object, you should see the script property have 2 variable, Drag anyone of the texture into variable texture1
5. Drag Your character object into variable mySkinnedMeshRenderer

Now if your character have 5 different part of Material you will see all of them turn into texture1

Hope this help


Sunday, November 18, 2012

Today Progress: character running into a building

So I figured to spend another 30 minute to put in the building that i have created and maybe open and closing door when the character running into the building


Today Progress: First animation in blender and Unity

So here is my first character animation in blender

and then i export it as .FBX file and then i run it inside unity

TADA!!!!!!!!

OH YEAH!!!!!!!!!!!!!

LITTLE BABY STEP PROGRESS!!!!!!


Blender how to animate object

Below is the tutorial I am following

summary
1. Drag 3 screen , top view normal , middle view Timeline, bottom view DopeSheet
2. Click "record" on your Dopesheet
3. Click the first keyframe in your timeline and move your object to position A
4. Click the second keyframe on time 24 and move your object to position B
5. Click play button on the timeline you can see your object move from A to B

Saturday, November 17, 2012

Blender how to weight paint inside vertex or face for noob

Here is what you should do

while in the "WEIGHT PAINTING" mode, press "ALT B" and select part of your character then you can paint it inside

see screen below


this is part of the finger, while I press "ALT B" then select half of the finger then you can see there are still some blue color inside the finger, then I can paint it red so the WEIGHT PAINT is correct

Friday, November 16, 2012

today progress, completing the body part

After following all the tutorial I manage to finish my body part , yes


put in the head


Blender creating amateur tutorial

Below is the tutorial I am following


Summary
1. Create an Amateur bone
2. In the bone property , tick X-RAY so you can see it inside the body
3. On edit mode, press the tip of the bone and press E to extrude a bone for the monkey head
4. On edit mode, press the tip of the bone, tick the "X-mirror" on left hand side and "SHIFT-E' to extrude two arm bone for the monkey
5. select the arm bone , press "ALT-P" to disconnect it from the parent, drag it to the arm
6. To do the leg, "SHITF-E" to extrude then 'ALT-P' to disconnect , 'G' to move it to the leg , 'R' to rotate, 'S' to resize
7. make sure all bone "ROLL " set to zero
8. on POSE MODE, add BONE constraint -> inverse kinematic-> chain length 2 to both lower leg and lower arm
9. on object mode, select your monkey mesh, APPLY-> ROTATION AND SCALE
10. Finally , "SHIFT select MESH and AMATEUR" then "CONTROL P" set to automatic weight

Tuesday, November 13, 2012

Today Progress : Building a body part

First step as screen shot below

Second step is to extrude the arm and neck and below is the result


Now to put back the head


And just in case you are wondering where do I find the tutorial to do this?

below is the link that I learn the tutorial from

Monday, November 12, 2012

Today Progress, creating a character face

Man I suck at blender, here is my 4th attempt to create a character face


so freaking ugly, but i have limited skill


Here is after another 5 minute of tweaking to make it cooler

Blender how to join and separate each object

Control - J to join Control - P to separate

Blender how to select multiple edge or vertices at the same time

Here is how to select multiple edge or vertices at the same time on blender

The most easy way is to press 'B' then you can draw a rectangle to select all within that rectangle

or you can SHIFT-RIGHT click each of them one by one

Today Progress, Create my first furniture house in Blender

So I have taken all that I have learned and created my first furniture house in blender


To help out the noob out there below is the shortcut key i Used

1. Press 'TAB' for edit mode
2. press 'G' to grab then press 'X', 'Y', or 'Z' to move in certain direction

3. press 'S' to scale then press 'X', 'Y', or 'Z' to scale in certain direction
4. press 'R' to rotate then press 'X', 'Y', or 'Z' to rotate in certain direction 

5. press 'TAB' for edit mode, then press 'K' to cut certain line, press space bar to confirm
6. press 'E' to extrude certain part
7. press ALT-CTL-Q to switch between 4 view and 1 view
8. Add few material and assign different material to different face of the object to color them

hope that help

Blender how to create 3D text

Below is the tutorial I am following on how to create 3D text using blender


Summary
1. Open Blender, Add -> Text
2. Object Modifier-> Add Modifier -> Solidify (Set to any thickness you want)
3. Press Tab to go to edit mode and type any word you want
4. To change color, Material -> add new Material -> Diffuse (change to any color you like)

Saturday, November 10, 2012

Blender How to create a house

Below is the tutorial I am following on how to create a house using blender




Summary
1. Open a new blender project, Scale your Cube so that it is big and flat
2. On edit mode, select the top face of the cube and press 'X' to delete the face
3. On edit mode, select the bottom face of the cube and press 'P' to separate it from the others, name it "FLOOR"
4. On edit mode, select the "FLOOR" and subdivide it multiple time, now you have 100 box
5. On edit mode, you can select a few box out of 100 box to make your wall, press 'E' to bring it up to become wall

Unity How to create terrain

Well, again, someone already doing some very awesome video, so I just share the link of the tutorial




Summary
1. Create a new terrain , then set resolution smaller maybe 100, 100, 100
2. Under the Terrain Script -> Paint Terrain Texture -> Edit Texture -> choose your texture file
3. Raise terrain height

Unity How to Create Main Menu

Well, I am not going to write tutorial as others have done it so well

below is the best tutorial i found on the net

http://active.tutsplus.com/tutorials/unity/getting-started-with-unity-finishing-our-game-with-a-menu/


summary
1. Create 2 scene, example "MainMenu", "Level1", open build setting and drag them in, make sure main menu scene on top
2. Game Object -> Create Other -> 3D Text, name it "PlayButton"
3. Create a java script, paste in this code, and drag it to your 3D text(PlayButton)


function OnMouseDown()
{
    // if we clicked the play button
    if (this.name == "PlayButton")
    {
        // load the game
        Application.LoadLevel("Level1");
    }
}

4. Click play and when you click the PlayButton it load level 1



Friday, November 9, 2012

Today Progress

So today I am going to build a character from scratch and then add in some bone then export it into unity

and below is the result


as you can see, i create a sphere, then i extrude the body, then i extrude both arm, then i add in some bone and attach it to the mesh, now i can move the character freely

I am lazy to do video so I only got one picture to show, sorry

Blender how to reduce polygon for noob

Here is how you can reduce polygon on Blender

1. select your object
2. On the right hand side, find Object Modifier -> Add Modifier -> Decimate
3. Then just put 0.5 to reduce 50% of your polygon


If you got error "Non-manifold mesh as input"

Here is how you fix it
1. Select the model, press "TAB" to enter edit mode and choose the menu option Select -> Non-Manifold

2. On Object Modifier -> Add Modifier -> Add Edge Split Modifier, set the edge angle to 90 degree then press apply

3. You will have 10% chance to fix it this way

But 90% chance you won't fix it,

So what is the next step?

You need to get Meshlab on the link below
 http://meshlab.sourceforge.net/

It is a free open source software

STEP
1. Download Meshlab
2. Open Meshlab, import your .obj Mesh
3. Filters -> Remeshing, simplification and reconstruction -> Quadric Edge Collapse Decimation


Tuesday, November 6, 2012

Unity Character moving in a wrong direction quick fix for noob

Ok, So today I face another problem where the character is moving sideway when I want him to move forward, no matter how i rotate the character it still move sideway

solution
1. Create an Sphere
2. Add character controller to the sphere
3. Make sure you can control the sphere nicely
4. Drag your character into the sphere (become his child)
5. Rotate your character

Now it will work, your character now can move forward when you want him to move forward

hope it help

Unity Character sink through floor quick fix

Today I faced one of the weird problem where after I place a character controller on my character and putting in walking script it sink through the floor

Anyway

Here is a quick solution

Please notice that under your Character Controller property there are

Radius: 0.5
Height: 2

I found that if you just change the Height from 2 to 1, your character won't fall anymore, I dunno why, if any pro out there can understand please explain to me, but it will fix the problem anyway

Sunday, November 4, 2012

Blender how to move a point across Axis Lock

Let say you want to move a point in your game object only along X, Y or Z

this is how you do it

1. First, select the point by right clicking it
2. PRESS "G" to grab
3. PRESS "X" then you can move it along x axis, PRESS "Y" then you move it along y axis, and PRESS "Z" then you can move it along z axis

hope that help

Blender how to assign different color to different face

Step by step Blender how to assign different color to different face

1.  Press "TAB" to go into edit mode
2. Make sure on bottom you choose "FACE SELECT"
3. Right click on one of your face in your cube
4. On right hand panel click "Material", add a few new material, set the "diffuse " to red for material 1, blue for material 2, green for material 3 example
5. Now you can click material 2 to set your face to blue, while other face remain red


hope that help

Blender how to cut a hole in your object

Here is a tutorial I study from the youtube


The summary
1. Press "tab" to go into edit mode, press "A" to select all
2. On left panel, choose "subdivide" , cut it 4 or 6
3. Choose the middle part, press x to delete its vertical, now you have a hole in your cube
4. To make a circle hole, you need to first select the edge of your hole, click "MESH" on bottom then MESH -> SNAP -> CURSOR TO SELECTED
5. Press OPTION+SHIFT+S (on IMAC) then you got your circle hole

Saturday, November 3, 2012

UV mapping on Blender

Below is the tutorial i study on youtube


To Summarize

1. Drag a second screen
2. On second screen, show UV editor
3. On first screen, press "A" to select all, then press "U" to unwrap your cube to the UV map
4. On second screen, press "A" to select all, press "R" to rotate, press "S" to scale
5. On second screen bottom, press UVs -> Export UV layout -> Export to your desktop cube01.png
6. Open cube01.png using your paint brush or gimp, put in color and number
7. On first screen, on top right , on the texture, type -> Image or Video, then open cube01.png
8. Under mapping -> coordinate -> choose UV
9. Render and see now it map perfectly on your cube
10.  On first screen, press "N" for property, under display -> Shading -> change to DLSL, then tick on the "TEXTURE SOLID" (make sure second screen you choose your cube01.png)
11. now you can see your pic on your cube without rendering



Friday, November 2, 2012

Unity how to change texture for game object using script

Here is the easy way

var myTexture : Texture;

gameObject.renderer.material.mainTexture= myTexture;



step by step how to do it in scrip
1. Create a new java script on your Unity
2. Paste in the code
3. Drag your script into one of your gameObject
4. Drag the texture you like into your gameObject variable myTexture


Unity How to generate random number

Here is the easy way

var mynumber: int;

mynumber = Random.Range(1,4);


//this will random number from 1 to 3, if you put (2,5) it will random number from 2 to 4

Unity prefab instance disappear itself after a while


Here is the code, enjoy


var lifeTime =1.0;

function Awake()
{
Destroy(gameObject, lifeTime);
}



1. Create a new javascript, paste in the code
2. attach this script to your game object prefab(example fireball)


Unity Prefab for Noob

Prefab is something you can add into your scene using the script, such as fireball or bullet

Step to create and use the Unity Prefab
1. Open Unity, under Asset -> Create -> Prefab
2. Drag your game object(fireball) into the new prefab you just created(under project tab)
3. Create a new Javascript


var YourPrefab: Transform;


function Update()
{
   if(Input.GetButtonDown("Jump"))
   {
      var bullit = Instantiate(YourPrefab, Vector3(x,y,z) , Quaternion.identity); 
      bullit.rigidbody.AddForce(transform.forward * 200);

   }
}

4. Drag your javascript to your Main Character
5. Drag your fireball prefab into your Main Character variable "YourPrefab"
6. Select your prefab, Component -> physics -> rigid body
7. Click play, you should be able to shoot fireball with your main character

the script check if the button "spacebar" is press, then it will create a new prefab(your fireball) out of thin air at the location you specify and will move with the force of 200 

Thursday, November 1, 2012

Error : Unknown identifier:'iTween' Solution for Noob

If you are using Unity and after you importing Itween and when you create a new simple javascript such as 


function Start () 
{
    iTween.MoveTo(gameObject,{"y":5} );
}


If you get error 
Error : Unknown identifier:'iTween'




here is the solution to fix this

first, please notice that your folder is ITWEEN -> PLUGIN -> itween.cs

So, first level = ITWEEN
second level = PLUGIN


move your PLUGIN folder to first level

so now your folder look like this 

ITWEEN
PLUGIN -> itween.cs

so both ITWEEN folder and PLUGIN are on the same level , first level

this will work and your error will be gone

hope this help, please note i spend 2 hour for fixing this, so I will really appreciate if you can leave a comment to thank me, thanks





Starting iTween for Unity for Noob

Here is a step by step how to use iTween to animate all your object in Unity for Noob

1. Open Asset Store and download "iTween"
2. Open Unity, create new project and make sure you import "iTween" on the checkbox
3. GameObject->Create Other -> Plane, set x,y,z to 0,-0.5,0
4. GameObject->Create Other -> Cube, set x,y,z to 0, 0, 0
5. GameObject-> Create Other -> Point Light , set x, y, z to 0, 2, 0
6. Drag the RotateSample or MoveSample to your Cube(under iTween-> Sample on bottom middle)
7. Click play and see your rube now rotating non stop



Thats it, you can move your cube anyway you want, for other list of stuff you can do, just follow the documentation here






Wednesday, October 31, 2012

I bought the unity 3d slot machine project

Below is the unity 3d slot machine project that I bought

http://activeden.net/item/unity-3d-slot-machine-prefab/405299?ref=phupang

to play it, just click the "Unity Player Preview"

then install the unity player plugin 500kb then can play

1. walk around using W,A,S,D
2. move close to the machine, then point your mouse to the "insert coin" and click to insert coin
3. move your mouse to "bet max" and click to spin
4. finally move you mouse to "cash out" and click to see your money popping out

pretty cool huh

its a bit expensive but it is well worth it

Wednesday, October 24, 2012

First Person Shooter and Third Person Shooter with Unity3D

Ok, So Today I have learned how to build a simple game using Unity3D

1. First Person Shooter

step1: create a new project -> import Character Controller.unityPackage and also Scripts.unityPackage
step2: create a floor (GameObject -> Create Other -> Plane)
step3: create a light (GameObject -> Create Other -> point light)
step4: on middle bottom, search for "first Person Controller", drag into left hand side(make sure it is on top of the plane)
step5: hit the run button on middle top and you can control your character to move around the floor


2. Third Person Shooter


step1: create a new project -> import Character Controller.unityPackage and also Scripts.unityPackage
step2: create a floor (GameObject -> Create Other -> Plane)
step3: create a light (GameObject -> Create Other -> point light)
step4: create your character( GameObject -> Create Other -> sphere)
step5: make sure you highlight your character(Sphere) then click Component-> Physic->Character Controller
step6: right click on bottom middle create new Javascript
step7: double click open your javascript and paste in the following code


var speed = 3.0;
var rotateSpeed=3.0;


function Start () {

}

function Update () 
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0,Input.GetAxis("Horizontal")*rotateSpeed,0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed=speed * Input.GetAxis("Vertical");
controller.SimpleMove(forward * curSpeed);


}

@script RequireComponent(CharacterController)




step 8: drag your javascript into the Sphere (you can now hit play and control your sphere)
step 9: To make the camera following your sphere, you need to search for "smooth follow" on middle bottom
step10: drag the smooth follow script into your main camera on the left
step11: drag the sphere into the your main camera smooth follow "target"
step12: run the game and you can control your sphere to move around the floor and the camera is following


Hope it help



I am so sorry I never came back for 2 whole month

I was playing games and watching tv and continue working for my daily job for this 2 whole month but I never gave up my dream to becoming a very successful game programmer

So I finally decided to stop playing online games and stay focus

Today I am going to learn how to make a 3D game instead, since I guess 3D is cooler and more challenging and if i can do it I rock

So the very first thing is to download blender , a free software that let you create your 3D object and then download Unity3D that you can use to code your 3D game

after playing around for 30 minute here is a product of my 3D character


yeah, yeah it suck ball but hey, this is my first 3D creation so give me a break

things that i learned
1. middle mouse click to rotate
2. tab to change to edit mode
3. right click to select the surface while in edit mode
4. E to extrude
5. Red ball to change color




Sunday, September 9, 2012

Okay I failed to quit my job

Ok, it been another 10 days and nothing have been going on

My boss ask me to continue to work for him as the project cannot finish and he cannot find another person to finish the thing off

So I agree to continue to work for him until the project is finish maybe another 2 to 3 months only afterward i can really "quit my job"

And in the mean time, I should really try to at least accomplish something

Monday, August 27, 2012

Its almost 2 months and I have finish nothing?

Well, I first started this blog on June and hoping to at least finish some simple game and I am not too proud to say that I failed, due to my laziness and just gaming and playing with my free time and not enough concentration and effort put into this

Well, guess I will start doing something today, yes, since I started my simple forex game, so I guess I will study how to plot a simple chart first for today objective

Okay after a 5 minute searching I found that there are 2 library I can use to plot the char, one is the power plot and one is the core plot

After a quick view for both, I found that power plot is more simpler even though the feature might be less, I will go for power plot then

Hmmm, after one hour of trying and coding and I am still failing, and I already feel tired, I will continue tomorrow and hopefully by then I can at least finish plotting a graph

Tuesday, August 21, 2012

Xcode how to convert integer to String for Noob

Here is how to convert integer to String in Xcode


 NSString *temp = [NSString stringWithFormat:@"%d", price];



So let say you want to convert integer "price" into String temp, above is how you do it

Xcode how to convert String to Integer for Noob

Here is Xcode how to convert String to Integer


int temp2 = [temp1 intValue];


Let say your temp1 is a String with value "100" it will convert into integer 100 in temp2

Xcode how to substring for Noob

There are 3 way to substring in Xcode

Let say Your String is "HelloRabbit"

NSString *aString = @"HelloRabbit"

First Way 

NSString *substring = [aString substringToIndex:7];
You will get: "HelloRab"
It mean you take the first character until the 7th character
Second Way 
NSString *substring = [aString substringFromIndex:5];
You will get "Rabbit"

It mean you take from the 5th character until the end


Third Way NSString *substring = [aString substringWithRange:NSMakeRange(5, 3)];

You will get "Rab"

It mean you start from character 5 and take only 3 character

Xcode how to Concat string and integer together for Noob

Here is how to Concat string and integer together for Noob


NSString *temp = [NSString stringWithFormat:@"Your Money: $%d, Price now is: $%d", money, price];


So your String is "Your Money:$, Price now is:$ " and your integer is money and price


New Update for today

So Today I continue to work on my simple forex game

where a single number on the middle will up or down

then there is 2 button for you to press to long or short

and in the middle is the list of item showing the position you long or short

in below screenshot


It look simple but the skill I learned to do this is as below

1. how to concat two string together
2. how to substring
3. how to convert string to integer
4. how to convert integer to string

I will make 4 post of simple tutorial later


Monday, August 20, 2012

Start New Game Instead of Continue Old one?

Ok, Instead of pushing my self to continue to finish the boring ass game, maybe I should start a new one instead?

Better than not doing anything right?

So what is my interested?

well, i guess I like to gamble stock and forex maybe I can create some simple forex game?

whatever, just as long as I can move my lazy ass to do something

So what is the first step?

First step is the whole idea, how should my game goes?

- a graph that randomly up and down, and a few button to click buy and sell, and profit

Ok, i just need to finish my first goal

man, believe it or not, just 10 days no touch the code, I feel like a complete noob again, i spend a total of 30 minute just to get 2 button up for me to click , and below is the code, under the init i will call the create button function to create 2 button for me to click, i am lazy to draw the button, so i use the CCMenuItemFont to show the Font button


        [self createbutton];
        


-(void)createbutton
{

    
    
    // Font Item
    CCMenuItem *item1 = [CCMenuItemFont itemFromString: @"LONG" target: self selector:@selector(Level1:)];

    
    CCMenuItem *item2 = [CCMenuItemFont itemFromString: @"SHORT" target: self selector:@selector(Level1:)];

    CCMenu * myMenu = [CCMenu menuWithItems:item1,item2,  nil];
    
    // Arrange the menu items vertically
    [myMenu alignItemsVertically];
    
    myMenu.position=ccp(170,140);
    
    
    // add the menu to your scene
    [self addChild:myMenu];

}


- (void) Level1: (CCMenuItem  *) menuItem 
{
    
NSLog(@"resume game was called");
}


And Below is the screenshot after my 30 minutes effort, OH MY GOD!!!!! so slow

ok, I cannot just stop here right, the next thing is to add a timer that will slowly increase the price or randomly change the price


- (void) myTimer:(ccTime)dt 
{
    smalltimer+=1;
    
    if(smalltimer==100)
    {
        smalltimer=0;
    
    
    
        NSString *temp = [NSString stringWithFormat:@"Price now is: %d", price];
    
        [mylabel setString:temp];
        price +=1;
    }
}

Here I just increase the price slowly every 2 seconds increase by 1, but I took a fine 10 minute just to research how to Concat the String and Int together, there are no simple + for this