Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Skyfall106_Gaming · May 07, 2017 at 10:08 AM · unity 5collisionterrain

Terrain Collider Bug

Hey! So Ive got a terrain and use my camera to control but whenever I run into the hill it doesnt use phycics and lets me go through it. Ive looked into it and it says save the scene but that doesnt work.... Anyone got a answer.

Comment
Add comment · Show 9
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 hexagonius · May 07, 2017 at 12:29 PM 0
Share

How do you run what? Be a little more precise

avatar image Skyfall106_Gaming hexagonius · May 09, 2017 at 10:41 PM 0
Share

Whenever I run my camera. I use my camera to control and when its going into the hill it literally goes into it. Sorry. I should of been more precise

avatar image RobAnthem · May 09, 2017 at 10:52 PM 0
Share

$$anonymous$$ore than likely this is not a bag, but a misunderstanding.

How are you moving your camera? Actual code being used would be helpful. Does your camera have a collider?

If your camera has no collider, OR is being moved without physics, then it will never "collide" without an outside force that IS using physics.

avatar image Skyfall106_Gaming RobAnthem · May 10, 2017 at 01:08 AM 0
Share

$$anonymous$$y camera doesnt have a colider and which one would I use if I add one. Also here is my movement script

[code] using System.Collections; using System.Collections.Generic; using UnityEngine;

public class WASD$$anonymous$$ove : $$anonymous$$onoBehaviour {

 public float ScrollSpeed = 15;

 public float ScrollEdge = 0.1f;

 public float speed = 4;

 public float PanSpeed = 10;

 public Vector2 zoomRange = new Vector2( -10, 100 );

 public float CurrentZoom = 0;

 public float ZoomZpeed = 1;

 public float ZoomRotation = 1;

 public Vector2 zoomAngleRange = new Vector2( 20, 70 );

 public float rotateSpeed = 10;

 private Vector3 initialPosition;

 private Vector3 initialRotation;

 void Start () {
     initialPosition = transform.position;      
     initialRotation = transform.eulerAngles;
 }


 void Update () {
     // panning     
     if ( Input.Get$$anonymous$$ouseButton( 0 ) ) {
         transform.Translate(Vector3.right * Time.deltaTime * PanSpeed * (Input.mousePosition.x - Screen.width * 0.5f) / (Screen.width * 0.5f), Space.World);
         transform.Translate(Vector3.forward * Time.deltaTime * PanSpeed * (Input.mousePosition.y - Screen.height * 0.5f) / (Screen.height * 0.5f), Space.World);
     }

     else {
         if ( Input.Get$$anonymous$$ey("d") ) {             
             transform.Translate(Vector3.right * speed * Time.deltaTime * PanSpeed, Space.Self );   
         }
         else if ( Input.Get$$anonymous$$ey("a") ) {            
             transform.Translate(Vector3.right * speed * Time.deltaTime * -PanSpeed, Space.Self );              
         }

         if ( Input.Get$$anonymous$$ey("w") ) {            
             transform.Translate(Vector3.forward * speed * Time.deltaTime * PanSpeed, Space.Self );             
         }
         else if ( Input.Get$$anonymous$$ey("s") ){         
             transform.Translate(Vector3.forward * speed * Time.deltaTime * -PanSpeed, Space.Self );            
         }  

         if ( Input.Get$$anonymous$$ey("q") ) {
             transform.Rotate(Vector3.up * Time.deltaTime * -rotateSpeed, Space.World);
         }
         else if ( Input.Get$$anonymous$$ey("e") ) {
             transform.Rotate(Vector3.up * Time.deltaTime * rotateSpeed, Space.World);
         }
     }

     // zoom in/out
     CurrentZoom -= Input.GetAxis("$$anonymous$$ouse ScrollWheel") * Time.deltaTime * 1000 * ZoomZpeed;

     CurrentZoom = $$anonymous$$athf.Clamp( CurrentZoom, zoomRange.x, zoomRange.y );

     transform.position = new Vector3( transform.position.x, transform.position.y - (transform.position.y - (initialPosition.y + CurrentZoom)) * 0.1f, transform.position.z );

     float x = transform.eulerAngles.x - (transform.eulerAngles.x - (initialRotation.x + CurrentZoom * ZoomRotation)) * 0.1f;
     x = $$anonymous$$athf.Clamp( x, zoomAngleRange.x, zoomAngleRange.y );

     transform.eulerAngles = new Vector3( x, transform.eulerAngles.y, transform.eulerAngles.z );
 }

} [/code]

avatar image RobAnthem Skyfall106_Gaming · May 10, 2017 at 01:44 AM 0
Share

Well there is your problem. You need to attach a collider to the camera, any collider would work. Then you need to attach a rigidbody to it, and move the object with physics via the rigidbody with Velocity, AddForce, or $$anonymous$$oveTowards.

Show more comments
avatar image Skyfall106_Gaming · May 10, 2017 at 05:50 AM 0
Share

2 Things. $$anonymous$$y terrain does have rigidbody so I will get rid of that but how would I move the camera without transform.translate? PS Ran out of replys so made a new comment

avatar image RobAnthem Skyfall106_Gaming · May 10, 2017 at 06:04 AM 0
Share

Well I wrote a tutorial on Velocity-based movement. Velocity-Based $$anonymous$$ovement 101

You can easily alter it to use AddForce if you prefer that as well. You'll get the hang of this sort of thing :) We all started somewhere, but try and do a bit of googling before asking any questions, even if you don't find an answer, it will help your Google-Fu, which is really one of our biggest assets as programmers.

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

Unity 5 no terrain collision 1 Answer

Can't crash airplane into ground 4 Answers

Camera Colliding with Terrain 1 Answer

Airplane - Collision With Terrain Problem 1 Answer

Stopping character from walking on grass 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