Advertisement

Camera Follow using C#

Started by August 24, 2019 06:45 AM
4 comments, last by Alberth 5 years ago

How to make a camera follow player movement in all directions using C# script, help me please

It would probably be useful to know what behavior you want exactly (there are various ways third-person cameras can be implemented), and what you've tried so far and in what way it's not doing what you want. (It also might be worth clarifying whether this is homework-related.)

I'll also mention that there are a lot of assets available for Unity, so if you're just looking for a pre-packaged solution and aren't that interested in learning about it yourself, you might look for something like that. (Not that I'm recommending this approach - I'm just mentioning it as an option.)

Advertisement
20 hours ago, Zakwayda said:

It would probably be useful to know what behavior you want exactly (there are various ways third-person cameras can be implemented), and what you've tried so far and in what way it's not doing what you want. (It also might be worth clarifying whether this is homework-related.)

I'll also mention that there are a lot of assets available for Unity, so if you're just looking for a pre-packaged solution and aren't that interested in learning about it yourself, you might look for something like that. (Not that I'm recommending this approach - I'm just mentioning it as an option.)

I really want to learn it. its not my homework or something, so i really appreciate you if you help me!

15 minutes ago, Jesterjoy3 said:

I really want to learn it. its not my homework or something, so i really appreciate you if you help me!

Some ideas:

- Search GDNet, the Unity forums, etc. for terms like 'third person camera' or 'follow camera'. You might find some example code.

- Look at Transform.LookAt() and see if you can get some ideas from that. The simplest possible third-person camera might involve positioning the camera appropriately and using LookAt() to aim it at the target. The code example in the documentation for LookAt() uses Update() for this, but it's common to use LateUpdate() to avoid jitter or other ordering issues. (This is all with the old GameObject system. I understand there's a new ECS system, but I haven't used it, so I can't comment on it.)

- If you run into problems, post what you've tried and what the problems are. Also, if you can find a video showing what sort of behavior you want, that could be helpful (there are various kinds of third-person cameras, so just saying you want to follow the player isn't quite enough information).

If you want to fundamentally understand what you're doing, start learning 3D math. There are lots of tutorials for that aimed at programmers.

This topic is closed to new replies.

Advertisement