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
1
Question by Dantevw1986 · Mar 14, 2012 at 12:21 PM · camera

First person controller, no gravity?

Is it possible to somehow set a "no gravity" mode to the first person controller? To get a airplane/fly simulation camera?

Im still new to unity, so this might be a very simple thing, but i cant find it so far.

thanx!

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
1

Answer by aldonaletto · Mar 14, 2012 at 12:55 PM

If you're using the First Person Controller that comes with Unity, you must modify the variable movement.gravity inside CharacterMotor.js (the script that controls the character movement). Place this code in a script attached to the character, and you can set the gravity value calling the function ChangeGravity(g):

function ChangeGravity(g: float){
  var chMotor: CharacterMotor = GetComponent(CharacterMotor);
  chMotor.movement.gravity = g;
}
If you want to start the game with a lunar gravity, for instance:

function Start(){
  ChangeGravity(1.6); // set a lunar gravity at start
}
The standard value is 10.0; if you set to 0.0, you will have no gravity at all.
Comment
Add comment · Show 8 · 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 Dantevw1986 · Mar 15, 2012 at 01:38 PM 0
Share

but in that case im still not able to move in the Z direction. it only allows me to go into X and Y somehow :/

avatar image syclamoth · Mar 15, 2012 at 01:57 PM 0
Share

Well, if there's no gravity, you won't fall down, however you still won't move upwards unless you add that too.

avatar image aldonaletto · Mar 16, 2012 at 02:28 AM 0
Share

@Dantevw1986, you're messing axes: you can move in X and Z, but not in Y (unless you jump or fall).
If you want to control vertical movement, it's better to write your own movement script, attach it to the character and disable the script Character$$anonymous$$otor. Since you don't want gravity, things are somewhat easier - for instance:

var speedH = 5.0; var speedV = 10.0;

function Update(){ var move: Vector3; move.x = Input.GetAxis("Horizontal") speedH Time.deltaTime; move.z = Input.GetAxis("Vertical") speedH Time.deltaTime; move.y = Input.GetAxis("$$anonymous$$ouse ScrollWheel") speedV Time.deltaTime; move = transform.TransformDirection(move); GetComponent(CharacterController).$$anonymous$$ove(move); } Attach this script to the character and disable Character$$anonymous$$otor, and you will be able to move up and down with the scroll wheel, as well as move around with the familiar AWSD keys. You will also be able to aim the camera to any direction with the mouse, because the character already have two scripts $$anonymous$$ouseLook that control the camera direction.

avatar image Dantevw1986 · Mar 19, 2012 at 11:34 AM 0
Share

what i have now, is a 3rd person controller, where the camera is attached to the mouse. Person walks in the direction of where the camera is facing to. So if i just hold down the W key for forward, the Character moves forward, but when i move the mouse to left and right, the movement direction changes, without using the A and D keys.

this is the same that i want, only now add the option to look up and down too. this does not work, even if gravity is 0 now.

any ideas on this one, or do you need the scripts i use now for that ?

avatar image fafase · Mar 19, 2012 at 11:46 AM 0
Share

is the "$$anonymous$$ouse ScrollWheel" on purpose there?

Show more comments
avatar image
-2

Answer by Obliviate · Sep 26, 2012 at 11:29 PM

I have a script that I came across, I changed a couple of things but it works and allows me to go up and down with no problems. The camera follows but I am still having trouble smoothing it out.. Hit me up on Skype if you want to take a look at it.. My Skype username is Lightning4771 upon add request tell me why your adding me.. :)

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

7 People are following this question.

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

Related Questions

How to make camera position relative to a specific target. 1 Answer

Camera Rotate behind rotating ball 1 Answer

Billboard without Update loop 0 Answers

how to find mouse look 1 Answer

How to take video input to unity ? 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