Question by
1Theo01 · Jan 15, 2018 at 02:07 AM ·
c#cameratransform.positionclampsmoothdamp
Mathf.Clamp does not work correctly in trannsform.position I'm trying to create a 2.5D game but I'm having trouble limiting camera movement
*using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cam_man : MonoBehaviour {
public Transform player;
public float speed;
public Transform ini;
public Transform fim;
public float temposuave;
public float speedfim;
public Vector3 speedfim3d;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update() {
player = GameObject.FindGameObjectWithTag("Player").transform;
ini = transform.parent.gameObject.transform;
fim = transform.parent.Find("cam_F");
speedfim = speed * Time.deltaTime;
Vector3.SmoothDamp(transform.position, player.position,ref speedfim3d,temposuave);
Mathf.Clamp(transform.position.x,ini.position.x,fim.position.x);
Mathf.Clamp(transform.position.y, ini.position.y, fim.position.y);
Mathf.Clamp(transform.position.z, ini.position.z, fim.position.z);
//transform.position = Vector3.Lerp(transform.position, player.transform.position, speed * Time.deltaTime);
}
}*
Comment
Your answer
Follow this Question
Related Questions
Question about Screen to World Point 0 Answers
how do i Limit camera rotation on Y-Axis 1 Answer
Clamping when Zoom changes? 0 Answers
Clamping camera inside a radius of a moving transformer 0 Answers