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 Ivan 1 · Feb 03, 2011 at 03:33 PM · movementmouse

FPS movement with mouse.

Hello,

I want to be able to move forward and back, and look left to right only (not strafe), all while holding down the left mouse button and moving the mouse accordingly. Can anyone help?

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

2 Replies

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

Answer by PrimeDerektive · Feb 03, 2011 at 04:33 PM

Didn't test this, but it should work:

var moveSpeed : float = 4.0; var rotSpeed : float = 2.0;

function Update () { if(Input.GetButton("Fire1"){ var mouseMove : float = moveSpeed Input.GetAxis ("Mouse Y"); var mouseRot : float = rotSpeed Input.GetAxis ("Mouse X"); transform.Translate(0, 0, Time.deltaTime*mouseMove); transform.Rotate (mouseRot, 0, 0); } }

Comment
Add comment · Show 3 · 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 Ivan 1 · Feb 03, 2011 at 07:21 PM 0
Share

Worked like a charm! Thank you very much! :)

avatar image PrimeDerektive · Feb 03, 2011 at 08:04 PM 0
Share

Glad to help :) Don't forget to mark as answered if you are satisfied.

avatar image nom-t · Jul 14, 2011 at 12:06 PM 0
Share

This script works but the problem is that it disables the collisions and the camera can go through the walls. How can i restore the collisions?

avatar image
0

Answer by Borgo · Feb 03, 2011 at 04:02 PM

Learn how to script and learn how to use the Input class.

If you have a specific question aboutyour script, create a detailed and specific question.

Here's some links:

http://unity3d.com/support/documentation/ScriptReference/

http://unity3d.com/support/documentation/ScriptReference/Input.html

There is some examples too.

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

1 Person is following this question.

avatar image

Related Questions

How to move GameObject by mouseclick? 1 Answer

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

Can someone help me with my TPS Controller/Camera? 1 Answer

Attach an object to the mouse cursor? 0 Answers

Mouse movement and click effect 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