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!!!!