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 eshonbel · Apr 21, 2014 at 05:37 PM · cameracollisionrigidbodycollider

Camera Collision Not Working

I am currently following Quill18Creates' Youtube Tutorial on making a 2D Game; Clony Bird. However, I am creating a FP 3D version and referencing to his 2D scripts and converting them. Everything has gone kind of well until it came down to my camera; my first person. It is a normal camera. I want to make it collide with the pipes and terrain, but it just goes through. I have placed a cube with a collider around it (parented) tried rigidbody and sphere/box colliders (triggered and not triggered). Here is the movement script so far.

 using UnityEngine;
 using System.Collections;
 
 public class BirdControl : MonoBehaviour {
 
     Vector3 velocity = Vector3.zero;
     public Vector3 gravity;
     public Vector3 flapVelocity;
     public float maxSpeed = 5f;
     public float forwardSpeed = 10f;
     
     
     
     bool didFlap = false;
     
     Animator animator;
     
     bool dead = false;
     
     // Use this for initialization
     void Start () {
     animator = transform.GetComponentInChildren<Animator>();
     }
     
     void Update () {
     if(Input.GetMouseButtonDown(0)) {
     didFlap = true;
         }
     
     }
     
     
     void FixedUpdate () {
     
     if(dead)
     return;
     
     velocity.z = forwardSpeed;
     velocity += gravity * Time.deltaTime;
     
     
     if(didFlap == true) {
     didFlap = false;
     if(velocity.y < 0)
     velocity.y = 0;
     
     velocity += flapVelocity;
     }
     
     velocity = Vector3.ClampMagnitude(velocity, maxSpeed);
     
     transform.position += velocity * Time.deltaTime;
     
     float angle = 0;
     if(velocity.y < 0){
     angle = Mathf.Lerp(0, -90, velocity.y / maxSpeed);
       }      
     transform.rotation = Quaternion.Euler(0, 0, angle);
       
           
     }
 
     void OnCollisionEnter(Collision collision) {
     animator.SetTrigger("Death");
     dead = true;
     
     
     }
     
     
 }

Because I'm referencing to quill18creates, (his original script) credit to him and his channel.

Comment
Add comment · Show 4
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 EvilTak · Apr 22, 2014 at 03:16 AM 0
Share

$$anonymous$$aybe using rigidbodies will be the best solution. Ins$$anonymous$$d of changing the transform's position, you can add forces to it or change rigidbody.velocity. And please make sure that you don't make your colliders as triggers because then they ignore collisions with rigidbodies.

avatar image eshonbel · Apr 22, 2014 at 07:29 AM 0
Share

As stated in the question, I have already tried rigidbodies but with no gravity and which are kinematic. I understand what Is Trigger is, I am just following the video.

avatar image Hoeloe · Apr 22, 2014 at 07:58 AM 1
Share

Looks like your biggest problem is not understanding what any of these settings do, and yet trying to use them anyway. Ins$$anonymous$$d of just checking options at random, look them up and find out what they do.

$$anonymous$$inematic Rigidbodies do detect collisions, but don't apply the physics step to them, so you won't get the Rigidbody moving after a collision - it will just continue on through it.

It's ALWAYS a good idea to try and understand WHY you're doing something, and WHAT it is you're doing, rather than just following a tutorial blindly.

avatar image eshonbel · Apr 22, 2014 at 03:29 PM 0
Share

Thanks for your reply, I unchecked the $$anonymous$$inematic and it worked. I understand the basics of colliders and whatnot, but unfortunately I'm not at the same level as most of all the clever Unity whizzes out there. In the video, he explained that Is $$anonymous$$inematic meant it won't be affected by gravity and stuff. However, he was using 2D Physics. Sorry for my bad question, and if you were to post an answer, I would tick it.

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

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

Camera gets flung off of the map when the player collides with certain objects. 0 Answers

why camera does not recognize the collision? 1 Answer

How to speed up? 3 Answers

Maintain velocity after impact with kinematic rigidbody 1 Answer

Fast object on collider not working 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