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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by IKilledKenny_2 · Jan 02, 2015 at 10:15 PM · camerajavascriptcharacterfollow

Character Runs Off Camera

Hello Unity3D i have a problem with my camera.The problem is my characters camera is auto targeting an enemy and whenever my character runs too far I can still see the enemy but i can't see the character that i have attached the camera to.What i want is no matter how far i go the camera still shows my character and the enemy.If anyone knows how i can do this.Can you please tell me how?

 var target : Transform;
 var moveSpeed = 20;
 var rotationSpeed = 5;
 var myTransform : Transform;
  
 function Awake() {
         myTransform = transform;
 }
  
 function Start() {
  
         target = GameObject.FindWithTag("Eye").transform;
 }
  
 function Update () {
    
     myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
     Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
 }
Comment
Add comment · Show 3
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 CrushBros · Jan 03, 2015 at 03:34 AM 0
Share

Wouldn't it be easier to set the transform in the inspector then trying to find a tag? And is your enemy tagged the same as your player?

avatar image IKilledKenny_2 · Jan 03, 2015 at 05:18 AM 0
Share

Well it finds the enemy automatically when the battle begins.So i thought this way was better no my enemy tag and my characters tags are totally different

avatar image CrushBros · Jan 03, 2015 at 10:24 AM 0
Share

So it changes target to the enemy from the player when it spots an enemy. Should probably enable a battle camera ins$$anonymous$$d that has a higher view point and a bounding box that zooms the camera in and out when combat starts.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by rantor88 · Jan 04, 2015 at 04:28 AM

When using a script to have a camera follow an object, whether in first person or third, its always best to use LateUpdate rather than Update. LateUpdate occurs after update, and is best for tracking movement. I dont know if this will stop the character from falling off the screen, but it might make a difference in camera lag.

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 IKilledKenny_2 · Jan 04, 2015 at 06:22 PM 0
Share

Hmmm...Intresting. What i was going to do was use the Var :ClampToScreen In order to make it that the character doesnt run off the camera.But alot of people tried and it didn't work for them.But ill try the LateUpdate ins$$anonymous$$d.Thank You Very $$anonymous$$uch!

avatar image
0

Answer by makegoalken · Mar 04, 2020 at 08:09 AM

Your feedback helps me a lot, A very meaningful event, I hope everything will go well enable flash in chrome

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

28 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

Related Questions

Camera animation into a scene –most efficient way? 2 Answers

AI navigating all 6 sides of a cube 0 Answers

Slightly Scrolling Camera 1 Answer

Smooth Follow Rotation 3 Answers

counting seconds that character is idle. 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