当前位置:网站首页>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;
}
}
边栏推荐
- 54. 螺旋矩阵 & 59. 螺旋矩阵 II ●●
- Séparation et combinaison de la construction du système qualité
- Unity and database
- Unity writes timetables (without UI)
- Looking at Chinese science and technology from the Winter Olympics: what is the mystery of the high-speed camera that the whole people thank?
- 2022 thinking of mathematical modeling a problem of American college students / analysis of 2022 American competition a problem
- Thinking of 2022 American College Students' mathematical modeling competition
- AutoCAD - command repetition, undo and redo
- Unity synergy
- 2022 American College Students' mathematical modeling ABCDEF problem thinking /2022 American match ABCDEF problem analysis
猜你喜欢
[groovy] closure (closure parameter binding | curry function | rcurry function | ncurry function | code example)
AutoCAD - graphic input and output
LeetCode之單詞搜索(回溯法求解)
[groovy] closure closure (customize closure parameters | customize a single closure parameter | customize multiple closure parameters | specify the default value of closure parameters)
Special information | real estate and office buildings - 22.1.9
The principle of attention mechanism and its application in seq2seq (bahadanau attention)
Solutions and answers for the 2021 Shenzhen cup
【Leetcode】1352. Product of the last K numbers
AutoCAD - isometric annotation
Recherche de mots pour leetcode (solution rétrospective)
随机推荐
Basic knowledge points of dictionary
stm32Cubemx(8):RTC和RTC唤醒中断
Leetcode word search (backtracking method)
2020-10-27
Autocad-- dynamic zoom
[groovy] closure (Introduction to closure class closure | this, owner, delegate member assignment and source code analysis)
中国溶聚丁苯橡胶(SSBR)行业研究与预测报告(2022版)
Redis 排查大 key 的4种方法,优化必备
GameObject class and transform class of unity
54. 螺旋矩阵 & 59. 螺旋矩阵 II ●●
猿人学第一题
Recherche de mots pour leetcode (solution rétrospective)
Unity synergy
flutter 对象和列表
mysql审计日志归档
[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
Common database statements in unity
Use assimp library to read MTL file data
2022 thinking of Mathematical Modeling B problem of American college students / analysis of 2022 American competition B problem