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 ryno9788 · Jun 01, 2015 at 03:35 AM · c#cameraplatformerfollow player

3d platforming Camera

I've been working on this camera rig were the camera rotates and follows around the player. I've already got the rotation taken care of in another script. What I've been looking how to do is trying to get the rig to only follow the player on the x and z axis using the players exact position. But i can't seem to find to call upon one of the transforms positions. the next part would be a smooth follow Y axis where you can see the player jump up and down the screen like you would see in Mario 64 and other classic 3d platformers.

I have been using this for the basic uses so far

 transform.position = player.position;

And if you show any examples of code please show it in c# other wise its fine Ill convert it.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Nabeel Akhtar · Jun 01, 2015 at 04:52 AM

Add these line of code and they will handle all

private Vector3 velocity = Vector3.zero;

void Update(){

camera.transform.position = new Vector3 (player.transform.position.x, Mathf.SmoothDamp (camera.transform.position.y, player.transform.position.y, ref velocity.y, 0.3f),player.transform.position.z);

}

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 ryno9788 · Jun 02, 2015 at 08:42 PM 1
Share

thanks works great had to modify it a bit though if (cameraSpeed>0){ cameraSpeed -= Time.deltaTime*ReachTime; } else { cameraSpeed = 0; } } else { cameraSpeed = camSpeed; } transform.position = new Vector3 (player.transform.position.x, $$anonymous$$athf.SmoothDamp (transform.position.y, player.transform.position.y, ref velocity.y, 0.03f* cameraSpeed), player.transform.position.z);

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

21 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to catch NullReferrenceExceptions in void Update 1 Answer

"Follow Target" script with a prefab (C#) Help me please! 1 Answer

Unity 2D Platfomer Enemy follow player only on x-axis, c# 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