Wednesday, 11 June 2014

# Free - NGUI Steering Wheel in C# for Unity3D Car Games (NGUI ile donen direksiyon kodu)


Hi all again, I was getting into car games but I needed a detailed, easy to use steering wheel. It had to be in NGUI and C#.

I have checked out all internet, and found one from "Yasir Kula", he nicely shared his code. But it was in Javascript and it designed to work with stock Unity3D gui.

So here, I have optimized his code, added some features, extremely easy to use and works nicely with NGUI, C# and EDY VEHICLE PHYSICS.

It is free to use,  at least you can thank me :)

-----------------------------------------------------------------------------------------------------------

using UnityEngine;
using System.Collections;

// Attach this to NGUI UIButton (Steering Wheel)
// Adapted from Yasir Kula
// AuthorOnur Mete Kaplan
public class CarSteeringWheel : MonoBehaviour {
    
    // NGUI UI Root camera (Not any other game play camera)
    public Camera camera;

    // Changable Data
    public float wheelAngleMax = 500.0f// 500 is an ideal number
    public float speedRotateBack = 1000.0f// Rotate back hydrolic speed

    // Rotation angle for EDY VEHICLE PHYSICS [Angle -1.0 to 1.0]
    public float wheelAngleScaledToOne = 0.0f;

    // Widget data
    private UIWidget uiWidget;

    // Wheel data
    private Vector3 wheelCenter;
    private float wheelAngle;
    private float wheelOldAngle;
    private bool isReset = false;
    
    // Touch data
    private bool isPressed = false;

    void Start () {

        // Get this widget
        uiWidget = this.GetComponent<UIWidget>() as UIWidget;
    
        // Get widget center
        wheelCenter = camera.WorldToScreenPoint(uiWidget.worldCenter);
        log("Widget Center: " + wheelCenter.ToString());
    }

    void Update(){

        // If user do not touch reset wheel for once
        if(!isPressed && !isReset){
            resetWheel();
        } 
    }
    
    void OnPress (bool isPressed){ 

        // Pressed to wheel
        this.isPressed = isPressed;

        // First touch to wheel
        wheelOldAngle = Vector2.Angle(Vector2.upnew Vector3(UICamera.lastTouchPosition.x - wheelCenter.xUICamera.lastTouchPosition.y - wheelCenter.y0.0f));
        
        // Not reset
        isReset = false;
    }
    
    void OnDrag(Vector2 delta){

        // Steer the wheel
        if(isPressed){

            // Do steering action
            doSteeringCalculations();
            doSteeringWidgetRotation();
        } 
    }

    private void doSteeringCalculations(){

        // Find new angle
        float wheelNewAngle = Vector2.Angle(Vector2.upnew Vector3(UICamera.lastTouchPosition.x - wheelCenter.xUICamera.lastTouchPosition.y - wheelCenter.y0.0f));

        // Touching very close to widget centerskip
        ifVector2.Distance(new Vector2(UICamera.lastTouchPosition.x,UICamera.lastTouchPosition.y), new Vector2(wheelCenter.xwheelCenter.y)) > 10f ){

            // Find final rotate angle
            if(UICamera.lastTouchPosition.x > wheelCenter.x){
                wheelAngle -= wheelNewAngle - wheelOldAngle;
            } else{
                wheelAngle += wheelNewAngle - wheelOldAngle;
            }
        }

        // Maximum angle (last check)
        ifwheelAngle > wheelAngleMax ){
            wheelAngle = wheelAngleMax;
        } else ifwheelAngle < -wheelAngleMax ){
            wheelAngle = -wheelAngleMax;
        }

        // Update angle
        wheelOldAngle = wheelNewAngle;

        // Log angle
        log("Wheel Angle: " + wheelAngle);
    }

    private void doSteeringWidgetRotation(){

        // Rotate the widget view
        this.transform.rotation = Quaternion.Euler(0f,0f,wheelAngle);

        // This is extra for EDY VEHICLE PHYSICS [Angle -1.0 to 1.0]
        if(wheelAngle != 0.0f){
            wheelAngleScaledToOne = -wheelAngle / wheelAngleMax;
        }else{
            wheelAngleScaledToOne = 0.0f;
        }
        log ("Wheel Angle Scale To One: " + wheelAngleScaledToOne);
    }

    private void resetWheel(){

        // if not resetted
        if(!Mathf.Approximately(0fwheelAngle )){

            // Log reset
            log ("Resetting wheel angle: " + wheelAngle);

            // Do widget view rotation
            doSteeringWidgetRotation();

            // Delta angle
            float deltaAngle = speedRotateBack * Time.deltaTime;

            // Check if is almost resetted
            ifMathf.AbsdeltaAngle ) > Mathf.AbswheelAngle ) ){
                wheelAngle = 0f;
                return;
            }
        
            // Continue reseting
            ifwheelAngle > 0f ){
                wheelAngle -= deltaAngle;
            }else{
                wheelAngle += deltaAngle;
            }

        } else{

            // Reset
            wheelAngle = 0.0f;
            wheelAngleScaledToOne = 0.0f;
            doSteeringWidgetRotation(); // Last check for %100 0.0f
            isReset = true;
        }
    }

    public void reset(){

        // Reset
        wheelAngleScaledToOne = 0.0f;
        wheelAngle = 0.0f;
        wheelOldAngle = 0.0f;
        isReset = false;
        isPressed = false;
    }

    private void log(string info){
        // Debug.Log("SteeringWheel " + info);
    }
}

Saturday, 3 May 2014

# Bonus - Amazing StartApp iOS Bonus Up To $1000




StartApp did it again. This is why like StartApp. They are straightforward and the only company I know that pays on the time without an excuse!

Here are the MAY bonus program for iOS;

Register here for MAY BONUS program
Click To Register

  • $50 bonus after only 1,000 impressions!
  • Earn $100 from your iOS apps and receive a $100 bonus!
  • Earn $500 from your iOS apps—get a $500 bonus!
  • Earn $1,000 from your iOS app—get a $1000 bonus!

Register here for MAY BONUS program, must be quick this for May only! Also for $50 you must use the referral link below.
Click To Register

Wednesday, 9 April 2014

#News - Get FREE Windows Mobile Phone & Get FREE Windows Pro 8 OS




Hello All,

I saw an amazing offer recently for Unity3D developer (Not a new offer, but I noticed recently)

If you plan to port your games Windows Phone App Store; 

You can go an register here to get AMAZING FREE STUFF

  • FREE Dev Center Account
  • FREE Windows 8 Licence
  • FFRE Developer Device (Phone or Tablet)
  • FREE priority review in app store
  • Much More...

Dont miss this :)


Monday, 10 March 2014

Why use StartApp - Mobile Advertisement $10,000 3D Ads !



INTRO

StartApp is my favourite Ad company, awesome support, really great ad types, reliable ECPM, clear and on-time payments!


REGISTER NOW

CLIKC HERE TO REGISTER (Help us for cost of tutorials, articles, development and support)


WHY ?

I have use many ad networks, nowadays it is even harder to make money with mobile ad networks, but StartApp is really much more reliable than others, of course it is not perfect, but better than others I can promise that.


USER LOVES 3D ADS

What is good is fresh 3D ADS (Users love 3D ads, this is the key of the success of StartApp)

  • Use Amazing 3D Banners
  • Use Great 3D App Wall
  • Try High ECPM Interstitials



LET'S MAKE MONEY

Register now, I promise you will not disappointed!

CLIKC HERE TO REGISTER (Help us for cost of tutorials, articles, development and support)

Lets make money, guys!

Good day :)

Saturday, 25 January 2014

Still not joined FREE DROPBOX!



Get started with dropbox FREE cloud storage for your backups, videos, photos, etc... Also support me for LibGDX, Mtx, Unity3D tutorials...

DropBox Registration Link: https://db.tt/WIxZp053


Tuesday, 24 December 2013

Tutorial 01 - Optimize Unity3D Game For Mobile Platforms (Android / iOS / Windows Phone)




Optimizing a game for mobile platforms are extremely important task. You may have nice graphics, nice gameplay and nice features, but if the game is not optimized enough, a glitchy game play, with lags, hiccups may ruin everything. All of these tiny issues will lead to low ratings and bad comments.

I have been working on Unity3D for a long time, in here I will make a list for all optimization tips for all mobile platforms (Android, iOS, WindowsPhone) and I will update regularly in future.


Sunday, 15 September 2013

StartApp new SDK - Earn Much More Money ($1000s) and Google Play Developer Policy Compliant





StartApp relased their new SDK today, and it is pretty good and %100 legal (Google Play Developer Policy Compliant)

Lets see what is in the basket
  • 3D Exit Ads (very cool looking and attractive for users)
  • Slider Search Ads (in-app ads and pay per download)
  • Post Call Ads ($8 for 1000 installs in the market, PRETTY AMAZING!)
  • And more...

StartApp is very good for begginners to make money! When you save enough money, you can make much better apps for users with IAPs (In-App Purchases). IAP is the future  of mobile sector.

Please register here and get $30 bonus, also help me to cover expenses of Mtx framework and this ad-free blog,  
REGISTER STARTAPP:  http://startapp.com/rf7snye

Happy day all :)



Saturday, 27 July 2013

# Developer Log - Why does LibGDX (Mtx) awsome with Unity3D ?


Hi my fellow developers, I have been extremely busy and working and working alot. Done couple of clients works, completed around 10-12 android apps, studying and learning about marketing, experimenting with ad networks, the most important one is I was focusing on Unity3D.

By the way some of our apps with other developers (sorry our strict policies) become very very successful, quite an achievement for us.



SECRET PROJECT
I have a top project with the highest priority at the moment. For my latest game (Still a secret) I made a simple level editor with LibGDX/MTX in only 3 days, this was awesome and essay. Game will be Unity3D the game.

Here is my simple level editor


How things will work ?
1. Create a level in LibGDX editor
2. Export level to xml file in a single second
3. Read xml file in Unity3D
4. Start Level



I AM A LAZY GUY, SO I NEED TO BE SMART
I decied this game around 1 week ago, it should be awsome and very long around 300 levels. I made the editor so that I can make a single level under 7-8 minutes :D and directly test the level in unity in 2 minutes, all together 10 minutes for a level, pretty awsome.



BUDGET
I bought these at the moment:
Unity3D NGUI: $95
Unity3D Galaxy Pack: $15

I will buy:
Epic Music Pack: $40
Some assets around: $25

Marketing :
Thinking around $1000 as start

So total will be around $1200 for the game, It is pretty cheap as you see for the start.




UNITY3D
I love LibGDX and Mtx, both very neat, easy to use, mostly error free, totally user control. For Unity3D I cant say same things, scripting is boring, untidy, editor with full of errors, stupid bugs, unknown backed crashes, so as you understand unity3d means unlimited problems.

On the other hand Unity3D is lighting fast, NGUI is awsome for GUIs. If I make a game with LibGDX in 30 days, I can make same game in Unity3D in around 6-7 days, no shitttinggg... The difference is FPS, LibGDX has awsome FPS, but Unity3D will not even open in many devices.



MTX
I of course continue my LibGDX adventure with Mtx, but nowadays I am very busy with learning, testing and other stuff... Mtx v2.1 still in beta but %100 functional without errors, so you can use it.





Take care everybody.