• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sagar123456789 · Jul 28, 2014 at 05:59 PM · characternottoable

not able to see my character

i am new in unity. i have created a character with game object and given it some animation .i also gave some touch code to work on my android device .following is the code and the clip to my scene and game mode

using UnityEngine; using System.Collections; [RequireComponent(typeof (Rigidbody2D))] [RequireComponent(typeof(BoxCollider2D))] public class animation : MonoBehaviour { public GUITexture guiLeft; public GUITexture guiRight; public float maxspeed=10F; bool facingright=true; Animator anim; int a=1;

 // Use this for initialization
 void Start () {
     anim = GetComponent<Animator> ();
 
 }
 
 // Update is called once per frame
 void Update () {
     if (Input.touchCount > 0) 
     {
         Touch t=Input.GetTouch(0);
         if(t.phase==TouchPhase.Began)
         {
             if(guiLeft.HitTest(t.position,Camera.main))
             {
                 FixedUpdate();
             }
             if(guiRight.HitTest(t.position,Camera.main))
             {
                FixedUpdate();
             }
         }
         if(t.phase==TouchPhase.Ended)
         {
             a++;
             FixedUpdate();
         }
     }


 }
 void FixedUpdate()
 {
     if (a > 0) 
     {
         rigidbody2D.velocity = Vector2.zero;
     }
     float move=Input.GetAxis("Horizontal");
     anim.SetFloat ("speed", Mathf.Abs (move));
     rigidbody2D.velocity = new Vector2 (move * maxspeed, rigidbody2D.velocity.y);
     if (move > 0 && !facingright)
                     Flip ();
             else if (move < 0 && facingright)
                     Flip ();



 }
 void Flip()
 {
     facingright = !facingright;
     Vector3 thescale =transform.localScale;
     thescale.x*=-1;
     transform.localScale = thescale;

 }

} alt text

game window.png (271.0 kB)
scene window.png (314.8 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

How to make camera not rotate with player, only move 1 Answer

It is not possible to invoke an expression of type 'SpriteManager[]'. 1 Answer

Character Controller Collision 4 Answers

Character Animation Wont Play 2 Answers

How can I make companion npcs follow the player's path, ala Chrono Trigger? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges