当前位置:网站首页>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;
}
}边栏推荐
- PR first time
- jmeter -- 分布式压测
- 3dsmax common commands
- [groovy] closure (Introduction to closure class closure | this, owner, delegate member assignment and source code analysis)
- 【acwing】837. Number of connected block points
- Common technologies of unity
- AutoCAD - Document Management
- 2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
- Function template
- 2021 electrician cup idea + code - photovoltaic building integration plate index development trend analysis and prediction: prediction planning issues
猜你喜欢

【acwing】240. food chain
![[groovy] closure (closure as function parameter | code example)](/img/a6/a4ed401acfb61f85eb08daa15a8a80.jpg)
[groovy] closure (closure as function parameter | code example)

PostgreSQL surpasses mysql, and the salary of "the best programming language in the world" is low

SQL set operation

【acwing】837. Number of connected block points

Establish cloth effect in 10 seconds

数论函数及其求和 待更新

2022 thinking of Mathematical Modeling B problem of American college students / analysis of 2022 American competition B problem

Detailed introduction of OSPF header message

How to choose a panoramic camera that suits you?
随机推荐
775 Div.1 B. integral array mathematics
猿人学第一题
An article takes you to thoroughly understand descriptors
775 Div.1 C. Tyler and strings combinatorial mathematics
The first topic of ape Anthropology
#775 Div.1 C. Tyler and Strings 组合数学
【acwing】240. food chain
Introduce Hamming distance and calculation examples
Redis 排查大 key 的4种方法,优化必备
Emlog blog theme template source code simple good-looking responsive
Create a pyGame window with a blue background
Flink cluster configuration
Judge the position of the monster in the role under unity3d
2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
mysql审计日志归档
Special information | finance, accounting, audit - 22.1.23
Flink集群配置
质量体系建设之路的分分合合
Database under unity
JVM 原理和流程简介