Unity 2D SMOOTH CAMERA FOLLOW Tutorial | Unity 2D Platformer Tutorial #3

preview_player
Показать описание
In this Unity 2D tutorial we're gonna do Smooth Camera Follow .
We will use SmoothDamp Method for Camera Follow system.
How To Clamp or Limit Camera Movement ?

Enjoy the video ☕

————————————————————————————
🖐 Hi Game developer
Welcome to Rehope Games I'm Murat

I share unity tutorial videos on my channel. if you want to make a game with unity (especially 2d platformer game), the videos here will definitely interest you.
————————————————————————————

#unitytutorials, #unity2d, #unity2dplatformer
Рекомендации по теме
Комментарии
Автор

Love your videos! Thank you & I hope you keep going with these!

DariiaPlaysMusic
Автор

Your simplicity is amazing. I love this series

Pixelgraft
Автор

always useful stuff, hope you doing great

totojatiwijayanto
Автор

Thank you- channel def deserves 1k subs

bobthebuilder
Автор

How about using cinemachine ? Is this the better way or would you prefer cinemachine?

ObitoUchiha-zuyn
Автор

I am getting this error:

Assets\Scripts\CameraController.cs(5, 14): error CS0101: The namespace '<global namespace>' already contains a definition for 'CameraController'

is there any way to fix this?

TaleAnimations
Автор

Bro u earned one sub from me.
thanks for the tutorial...

purple_larry
Автор

wouldn't it be easier to just use cinemachine?

Kitoniarz
Автор

hello,

Hope you are well.

I really like your videos, up until now everything was clear to me, but in this video I got into some trouble.

After I added this to the camera controller the position of the camera moved in every direction. Z was not -10 anymore, the position of x and y changed also. So I could not see the player anymore.
[Header("Axis Limitation")]
public Vector2 xLimit;
public Vector2 yLimit;

targetPosition = new Vector3(Mathf.Clamp(targetPosition.x, xLimit.x, xLimit.y), Mathf.Clamp(targetPosition.y, yLimit.x, yLimit.y) - 10);



Did I do anything wrong? Before I add this lines was working perfect. Bellow is the full script



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour
{
Transform target;
Vector3 velocity = Vector3.zero;

[Range(0, 1)]
public float smoothTime;

public Vector3 positionOffset;


[Header("Axis Limitation")]
public Vector2 xLimit;
public Vector2 yLimit;



private void Awake()
{
target =
}

void LateUpdate()
{
Vector3 targetPosition = target.position + positionOffset;
targetPosition = new Vector3(Mathf.Clamp(targetPosition.x, xLimit.x, xLimit.y), Mathf.Clamp(targetPosition.y, yLimit.x, yLimit.y) - 10);
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);
}
}

laszlo-csabatorok
Автор

i have problems: i hsave script of Camera controller. I did all by your steps -> all working, then when i forgot to save file all disappeared, but scripts are remained. Then when i redo all of that, camera controller script stopped working. Like i repaced main camera position, but when i starting game camera didnt following the player. What should i do?

kirillkolpin
Автор

I have a problem with this guide. the camera is chasing the player, but when moving the camera along the x-axis, stutters are visible
any solutions?

Pashdet
Автор

Amazing tutorial, everything works well - but why not use cinemachine instead?

wormholeinteractive
Автор

What's the difference between normal camera movement and this script

tharunsai
Автор

Vector3' không chứa định nghĩa cho 'smoothDamp' T-T

lorihihi