Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
avatar image
0
Question by Benifir · Sep 04, 2013 at 08:59 AM · movement scriptc

Problem with Joystick?

Alright, I've got a problem with my joystick. I'm an adept programmer but this is my first project working on an IOS application and I just can't find out how to fix the problem. Here is the function that controls the ships movement:

     public void MoveShipJoystickFixedUpdate() {
         rigidbody.AddRelativeForce(0, 0, normalizedSpeed * forwardForce);
 
         Vector3 accelerator = _joystick.transform.position;
         
         // Rotate turn based on acceleration        
         euler.y += accelerator.x * turnSpeed;
         // Since we set absolute lean position, do some extra smoothing on it
         euler.z = Mathf.Lerp(euler.z, -accelerator.x * maxTurnLean, 0.2f);
         
         // Since we set absolute lean position, do some extra smoothing on it
         euler.x = Mathf.Lerp(euler.x, accelerator.y * maxTilt, 0.2f);
         
         // Apply rotation and apply some smoothing
         Quaternion rot = Quaternion.Euler(euler);
         transform.rotation = Quaternion.Lerp (transform.rotation, rot, sensitivity);
 
     }

I didn't find anything wrong with that but it ties in closely with the Joystick script. Of which I got from the Unity Wiki: http://wiki.unity3d.com/index.php/Joystick. I need to know how to tie into my movement script. It apparently doesn't change the position of the GameObject, it seems that is only changes the pixel inset location of the joystick texture? It needs to give a value between -1 and 1. Is there some way I can get the movement of the joystick to return between those values? Any advice is greatly appreciated but you'll need to take a glance at the Joystick.cs to understand what I'm saying.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by syclamoth · Sep 04, 2013 at 11:29 AM

Get rid of the '.transform' in the middle. It should just be '_joystick.position' (assuming the _joystick variable is referring to the Joystick script instance).

Comment
Add comment · Show 1 · 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 Benifir · Sep 04, 2013 at 11:48 AM 0
Share

That did it. Thanks, I was referencing the variable to the gameObject of the tag "Joystick", thus the transform.position. Referencing it the Joystick.cs instance cleared it up.

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

17 People are following this question.

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

Related Questions

C - compare 2 char 0 Answers

Making rigidbody force movement snappy 4 Answers

How do I make it so that when my player enters an area, a disabled script attached to my player becomes active? 1 Answer

How to make Dual Joysticks for Android and IOS? 1 Answer

FPS controller, only for use on object 0 Answers


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