当前位置:网站首页>Unity shot tracking object
Unity shot tracking object
2022-07-05 04:55:00 【yoyoHm】
The camera moves smoothly with the character
// Design content :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour {
public Transform m_TargetTransform; // The target to be tracked by the camera
private float depth = -18f; // The front and back position of the lens relative to the character , A negative number means being behind the character ;
private float height = 40f; // The height of the lens relative to the upper part of the character ;
[SerializeField]
private float m_Speed = 12f; // Control the speed of lens tracking , Used to adjust the lens forehead to move smoothly , If the speed is too high , In extreme cases, the target position is directly assigned to the lens , So for the blinking effect of characters like flash , Will bring adverse visual images
void Update()
{
if (m_TargetTransform != null)
{
var targetposition = m_TargetTransform.position + new Vector3(0, height, depth);
transform.position = Vector3.MoveTowards(transform.position, targetposition, m_Speed * Time.deltaTime);
}
}
public void SetTarget(Transform target)
{
m_TargetTransform = target;
}
}边栏推荐
- 计组笔记(1)——校验码、原补码乘除计算、浮点数计算
- Unity connects to the database
- On-off and on-off of quality system construction
- Number theoretic function and its summation to be updated
- [groovy] closure (closure call is associated with call method | call () method is defined in interface | call () method is defined in class | code example)
- AutoCAD - stretching
- Emlog博客主题模板源码简约好看响应式
- 2020-10-27
- 中国金刚烷行业研究与投资预测报告(2022版)
- 2021 huashubei mathematical modeling idea + reference + paper
猜你喜欢

Thinking of 2022 American College Students' mathematical modeling competition

AutoCAD - feature matching

Group counting notes (1) - check code, original complement multiplication and division calculation, floating point calculation

次小生成树

Create a pyGame window with a blue background

質量體系建設之路的分分合合

XSS injection

An article takes you to thoroughly understand descriptors

Solutions and answers for the 2021 Shenzhen cup

3dsmax scanning function point connection drawing connection line
随机推荐
Establish cloth effect in 10 seconds
Mode in BST (binary tree & Notes on question brushing)
数论函数及其求和 待更新
【acwing】528. cheese
Unity writes timetables (without UI)
669. 修剪二叉搜索树 ●●
Number theoretic function and its summation to be updated
PostgreSQL surpasses mysql, and the salary of "the best programming language in the world" is low
AutoCAD - scaling
2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
[Chongqing Guangdong education] National Open University 2047t commercial bank operation and management reference test in autumn 2018
Forecast report on research and investment prospects of Chinese wormwood industry (2022 Edition)
Autocad-- dynamic zoom
History of web page requests
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)
MySQL in-depth learning - index creation and deletion, index design principles, index failure scenarios, query optimization, index push down ICP
54. Spiral matrix & 59 Spiral matrix II ●●
Rip notes [rip message security authentication, increase of rip interface measurement]
Fluent objects and lists
Unity parallax infinite scrolling background