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 AlexFili · Sep 22, 2012 at 03:06 PM · cameramovementplayer

Third-Person Camera keeps intersecting with terrain/buildings

I need to add some collider to the default Third-Person Camera so that it doesn't clip through the geometry/other objects. What should I do? Are there any code examples which add mouse controls to the Third Person Camera, like in a standard third-person shooter game with the right analog stick?

Also, what's the best way of making the down button work as 'backwards' rather than 'turn 180 degrees'?

Thanks.

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
0

Answer by MountDoomTeam · Sep 22, 2012 at 07:01 PM

hiya, add an invisible capsule around it with a collider as parent or child, is a quick fix, that's a tricky one! advanced games probably have complicated code to make the camera follow in the middle of corridors etc. do some more research about camera smoothers and third person camera control in unity, theres alot of talk about it.

here is some navigation code for a spaceship with shoot taken from worm game tutorial.

also chck out the mouse orbit scripts for mouse camera orbit rotations.

 var speed = 15.0;
 var rotspd = 10.0 ;
 var bullitPrefab : Transform;
 
 
 function Update ()
 { 
 
 
 if ( Input.GetKey("mouse 1") )
  {constantForce.relativeForce = 15000 * Vector3.forward
 ;}
 else 
  {constantForce.relativeForce = Vector3.zero;}
     if(Input.GetButton("forwards"))
      { 
               transform.eulerAngles.x += rotspd * Time.deltaTime * 7;
      }             
      
           if(Input.GetButton("backwards"))
      { 
               transform.eulerAngles.x += -rotspd * Time.deltaTime * 7;
      }        
      
           if(Input.GetButton("left"))
     {
               transform.eulerAngles.y += -rotspd * Time.deltaTime * 7;
      }        
      
           if(Input.GetButton("right"))
      { 
              transform.eulerAngles.y += rotspd * Time.deltaTime * 7;
      }        
 
     
        //  if(Input.GetButton("Fire1")) 
       //{ 
      // var bullit = Instantiate(bullitPrefab, transform.Find("spawnPoint").transform.position, Quaternion.identity);
       //bullit.rigidbody.AddForce(transform.forward *8000);
      // }
       
 }     
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 MountDoomTeam · Sep 22, 2012 at 07:02 PM 0
Share

backwards is opposite of this:

if ( Input.Get$$anonymous$$ey("mouse 1") ) {constantForce.relativeForce = 15000 * Vector3.forward ;}

avatar image
0

Answer by T27M · Sep 22, 2012 at 07:55 PM

I watched a video on YouTube(Link) @ about 4.50. Its a devlog of him making a game.

Basically the way he had his 3rd person camera setup is to cast a ray from the player to a plane that is tracked to the player. The camera would the be placed on the point where the ray hits. If something got in the way of the plane say a wall for example then the camera would be placed on the wall where the ray hits.

Might be worth a try scripting that system up.

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

11 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

Related Questions

A node in a childnode? 1 Answer

Player Laggs/Shakes while making movement[Android] 1 Answer

Problem with player movements 1 Answer

Keep camera away from head while using Lerp 0 Answers

Flickering screen when development build disabled 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