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 /
avatar image
0
Question by zero_equals_zero · Jun 06, 2014 at 09:36 PM · mousemove

MouseY movement

Hi I would like to move my ship towards the Y axis of the mouse, i've checked the game input to mouseY

So far I have the code pasted below. Also a screenshot to elaborate this issue I have an object with no rotation but the camera is rotated -90 to show a side view. I have no gravity selected.

The top and bottom of the ship are in the scene editor 1.4 and -1.4 ( aka the min & max a ship could move thus its boundaries )

However the ship never reaches my max or min point as you can see in the screenshot. Its like it has a sort of delay or offset.

I am new to unity, i have many years of AS3 knowledge but awkwardly new to unity, but loving it! and so far I can't seem to bend my head around it. Thank you!

 using UnityEngine;
 using System.Collections;
 
 [System.Serializable]
 public class Boundary
 {
     public float xMin, xMax, zMin, zMax, yMin, yMax;
 }
 
 public class PlayerController : MonoBehaviour
 {
     public float speed;
     public float tilt;
     public Boundary boundary;
     
     void FixedUpdate ()
     {
         float moveHorizontal = Input.GetAxis ("MouseY");
         //float moveVertical = Input.GetAxis ("Vertical");
         Vector3 movement = new Vector3 (0.0f, moveHorizontal);
         rigidbody.velocity = movement * speed;
         
         rigidbody.position = new Vector3 
             (
                 0.0f, 
                 Mathf.Clamp (rigidbody.position.y, boundary.yMin, boundary.yMax), 
                 0.0f
                 );
 
         rigidbody.rotation = Quaternion.Euler (0.0f,0.0f, rigidbody.velocity.y * -tilt );
     }
 }

![alt text][1] [1]: /storage/temp/27392-screenshot-2014-06-06-22.49.25.jpg

screenshot-2014-06-06-22.49.25.jpg (386.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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Dizzyman572 · Jun 06, 2014 at 10:46 PM

I've plugged in your code into unity and it seems that the code is working perfectly. I even played around with the settings and the cube never went past the min and max limit. Other than the cube jitterbugging a bit the code just seems fine in my perspective. Are you sure you didn't accidentally pressed "14" instead of "1.4" for min and max setting, that's the only possible fix I can up with. Or am I misinterpreting your problem entirely?

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

22 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Diablo 3 like move to mouse (w/o click) - efficient? 1 Answer

How to make the mouse and light binding 0 Answers

Folow mouse script 0 Answers

Moving objects with *Isometric* mouse position (JS) 1 Answer

Moving object with mouse, without clicking 2 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