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 pintee · May 07, 2012 at 04:01 AM · 2dcollision detectionsmooth follow

Smooth Follow in a 2D Game

Hi, I am making a 2d game where the camera follows a player along the xy axis. So if the character moves up or down the camera scrolls along with it to make sure that the player is always in the middle of the screen. Say the player is moving upwards and the camera is happily scrolling along with it when all of a sudden the player bumps into an obstacle. The camera is supposed to stop scrolling upwards. My problem is I can't get the camera to stop completely once it hits the obstacle. It slowly creeps upwards when i reverse and bump into the obstacle again….How do I get a camera to stop moving when the player hits an obstacle???

Comment
Add comment · Show 5
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 Lo0NuhtiK · May 07, 2012 at 04:02 AM 1
Share

Try childing the camera to the player and not having the follow script attached, then it'll tag-along with player because it'll be a part of it. (guess that's what you meant you wanted anyway)

avatar image pintee · May 07, 2012 at 04:27 AM 0
Share

a clearer question -_-

how do you tell if the player has stopped moving because it has hit an obstacle? It still has velocity, it just doesn't go anywhere.

avatar image syclamoth · May 07, 2012 at 04:30 AM 0
Share

If it's not going anywhere, it has no velocity. By definition. You probably need to improve your physics simulation.

avatar image pintee · May 07, 2012 at 05:28 AM 0
Share

Lo0Nuhti$$anonymous$$: I am doing something a bit more complicated where the camera doesn't follow the player in the negative x, only in the positive. If I child the camera to the player, it will follow in both directions.

syclamoth: When I print out target.velocity.magnitude it says 10...but when i also print out the y position it remains the same so i don't know whats going on there...what i need is a way to tell if an object is moving( i tried the suggestion at http://answers.unity3d.com/questions/34303/deter$$anonymous$$ing-if-a-collider-has-stopped.html but the camera still keeps scrolling a bit after the player has stopped).

avatar image Lo0NuhtiK · May 07, 2012 at 05:41 AM 0
Share

yeah, I got that when you posted your other comment earlier.

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

6 People are following this question.

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

Related Questions

Problem with method Collider2D.isTouchingLayers() 4 Answers

Collision & 2D 2 Answers

Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement 1 Answer

[2D] Getting particles to collide with a game object(Explosion debris effect) 0 Answers

C# Collision Script 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