Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by stoner221 · Aug 11, 2012 at 08:08 AM · animationandroid

Scripting Animation to Android camera relative controller

hey there well soo far i was able to script my left joystick to handle all my run animations but iam having trouble setting up the right joystick soo that it controls the look left.right,up,down movement's.. iam able to do most of my functions like fire relode ect,, but just stuck on that right joystick.. here is what the code looks like soo far

 var reload:AnimationState;
 var swap:AnimationState;
 var fire:AnimationState;
 var hit:AnimationState;
 var up:AnimationState;
 var down:AnimationState;
 var right:AnimationState;
 var left:AnimationState;


 function Start(){
 //NotificationCenter.DefaultCenter().AddObserver(this,"");
 //NotificationCenter.DefaultCenter().AddObserver(this,"");
 NotificationCenter.DefaultCenter().AddObserver(this, "Gameover");
 NotificationCenter.DefaultCenter().AddObserver(this, "Reload");
 NotificationCenter.DefaultCenter().AddObserver(this, "SwapWeapon");
 NotificationCenter.DefaultCenter().AddObserver(this, "Fire");
 NotificationCenter.DefaultCenter().AddObserver(this, "FireShotgun");
 NotificationCenter.DefaultCenter().AddObserver(this, "PlayerHit");
 
 reload = animation["reload"];
 reload.layer = 1;
 reload.blendMode = AnimationBlendMode.Additive;
 
 swap = animation["swap"];
 swap.layer = 1;
 swap.blendMode = AnimationBlendMode.Additive;
 
 fire = animation["fire"];
 fire.layer = 1;
 fire.blendMode = AnimationBlendMode.Additive;
 
 hit = animation["hit"];
 hit.layer = 1;
 hit.blendMode = AnimationBlendMode.Additive;
 
 }
 var isDead:boolean = false;

 function Gameover(){
 isDead = true;
 animation.CrossFade("death",0.1);
 }

 function Reload(){
 animation.CrossFade("reload",0.1);
 }

 function SwapWeapon(){
 animation.CrossFade("swap");
 }

 function Fire(){
 animation.CrossFade("fire",0.1);
 }

 function FireShotgun(){
 animation.CrossFade("fire",0.1);
 }

 function PlayerHit(){
 animation.CrossFade("hit",0.1);
 }


 var JoystickScriptMove:Joystick;
 var JoystickPosMove:Vector2;
 var JoystickScriptRotate:Joystick;
 var JoystickPosRotate:Vector2;

 function Update () {
 if (!isDead) {
 //Debug.Log(JoystickScriptMove.position);
 //Debug.Log(JoystickScriptRotate.position);
 JoystickPosMove = JoystickScriptMove.position;
 JoystickPosRotate = JoystickScriptRotate.position;
 
 
 if (JoystickPosRotate.y > 0.4) {
 up = animation["up"];
 up.layer = 1;
 up.blendMode = AnimationBlendMode.Additive;
 animation.CrossFade("up");
 } else if (JoystickPosRotate.y < -0.4) {
 down = animation["down"];
 down.layer = 1;
 down.blendMode = AnimationBlendMode.Additive;
 animation.CrossFade("down");
 
 } else if (JoystickPosRotate.x > 0.4) {
 right = animation["right"];
 right.layer = 1;
 right.blendMode = AnimationBlendMode.Additive;
 animation.CrossFade("right");
 
 } else if (JoystickPosRotate.x < -0.4) {
 left = animation["left"];
 left.layer = 1;
 left.blendMode = AnimationBlendMode.Additive;
 animation.CrossFade("left");
 }
 
 
 if (JoystickPosMove.y > 0.4) {
 animation.CrossFade("forward");
 } else if (JoystickPosMove.y < -0.4) {
 animation.CrossFade("backwards");
 } else if (JoystickPosMove.x > 0.4) {
 animation.CrossFade("rightStraff");
 } else if (JoystickPosMove.x < -0.4) {
 animation.CrossFade("leftStraff");
 } else {
 animation.CrossFade("idle");
 }
 
 }

 }
Comment
Add comment · Show 1
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
avatar image stoner221 · Aug 13, 2012 at 02:56 PM 0
Share

anybody have a clue on this at all???

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Loius · Aug 13, 2012 at 05:35 PM

Edit > Project Settings > Input?

It looks like the problem is in Joystick, not this file.

Comment
Add comment · Show 2 · Share
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
avatar image stoner221 · Aug 15, 2012 at 11:52 PM 0
Share

no that wasn't the problem looked at it everything was in order i have on more idea going to comment the animations for the run and try to see if my joysticks are indeed out of place but thanks for the reply:)

avatar image stoner221 · Aug 15, 2012 at 11:59 PM 0
Share

plus the input manager has nothing to do with android or ios

avatar image
0

Answer by stoner221 · Aug 16, 2012 at 07:48 PM

well i figured it out my script was correct but i just needed to clamp forever my animations then it worked perfect.. then just changed the animation layers then worked like a charm hope that script helps others :)

Comment
Add comment · Share
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

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.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Need help with script 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Which script should I use if I want my character to move to the Z direction automatically when I play, being able to change the speed?? 0 Answers

How to get gun to move with models hand? 1 Answer

Animated Texture Offset 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges