• 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 /
  • Help Room /
avatar image
Question by natezos07 · Nov 28, 2022 at 08:31 AM · cameracamera-movementcamera rotatecamera-lookcamera follow

I'm too dumb to make a Tekken-like camera, can someone help me with it?

I'm trying to make a game that is basically a Tekken clone, and I've spent three days on the camera. I have the movement and zooming in, but I can't decide the direction it points in. I want to always be to side of the players, like this: alt text

I'm to dumb to that though, I've tried at least 11 different solutions, and none of them work. If anyone knows what I'm doing wrong, could you help me fix it, maybe? Thanks :D

 (
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class CameraZoom : MonoBehaviour
 {
     public GameObject player1;
     public GameObject player2;
     public Vector3 offset;
     private Vector3 pos;
     public Transform test;
     public float zoom;
     private float comparison;
     public float divDist;
     public Vector3 center;
     
     public void LateUpdate()
     {
         pos = 0.5f * (player1.transform.position + player2.transform.position);

         float dist = Vector3.Distance(player1.transform.position, player2.transform.position);
 
          divDist = dist / zoom;
 
         test.position = pos;
         transform.position = pos;
 
         if(divDist < 0.5104699f)
         {
             divDist = 0.5104699f;
         }
 
         center = ((player2.transform.position - player1.transform.position) / 2.0f) + player1.transform.position;
         transform.LookAt(center);

         transform.position = (pos - offset * divDist);
     }
 }
 )
pain.jpg (20.7 kB)
Comment

People who like this

0 Show 2
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 natezos07 · Nov 27, 2022 at 08:58 PM 0
Share

sorry put it in twice, i forgot to sign in

avatar image SurreyMuso natezos07 · Nov 28, 2022 at 09:17 AM 0
Share

Don't worry - I fixed that for you...

1 Reply

  • Sort: 
avatar image

Answer by SurreyMuso · Nov 28, 2022 at 09:31 AM

OK, forget everything you've done so far! You definitely want to use a Unity Package called Cinemachine but you have to install it first. Window > Package Manager > Unity Registry > Cinemachine

It's going to take you a little while to get into it and I strongly recommend a good tutorial. learn.unity.com has some tutorials but they're not as good as some independents on YouTube. Search there and find one that matches your skill level.

It may look like a heavy solution to your problem but you must use it. It will help you move the camera, keep characters in frame and avoid all those problems of rotation that you are probably finding now by manipulating the camera yourself.

One thing. If you watch an older tutorial (Cinemachine version 2.7.0 and older) you may struggle to find the Cinemachine menu. Since Cinemachine 2.7.1, it's under the GameObject menu in the Unity Editor.

Comment

People who like this

0 Show 0 · 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

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

273 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 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

CineMachine Camera Movement is inverse 1 Answer

Spyro Like Camera Follow 0 Answers

Make Camera follow rotation of 2 Players 1 Answer

C# Smooth Follow Space Ship 1 Answer

When attaching my custom camera script camera shakes when player starts to move fast. 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