当前位置:网站首页>[100 unity practical skills] | make the skills or equipment follow the character and rotate continuously in the game
[100 unity practical skills] | make the skills or equipment follow the character and rotate continuously in the game
2022-06-21 12:18:00 【Hua Weiyun】

This paper is written by A little fool Typing Code Y original
The learning column recommends :Unity Systematic learning column
Recommended in the game production column : Game making
Unity actual combat 100 Example column recommendation :Unity actual combat 100 example course
Welcome to thumb up Collection Leaving a message. Please correct any mistakes !
The future is long , It's worth our effort to go to a better life
------------------️ Split line ️-------------------------
Unity Little science popularization
Old rules , Let me introduce you Unity A little knowledge of popular science :
- Unity yes real time 3D Interactive content creation and operation platform .
- Include Game development 、 The fine arts 、 Architecture 、 Automobile design 、 Movies All creators including , With the help of Unity Turn ideas into reality .
- Unity The platform provides a complete set of software solutions , Can be used to create 、 Operate and realize any real-time interactive 2D and 3D Content , Support platforms include mobile phone 、 The tablet 、PC、 Game consoles 、 Augmented reality and Virtual reality device .
- You can also simply put Unity Understood as a The game engine , It can be used for professional production game !
Unity Step on the pit to learn a little knowledge
Unity Make one object rotate with another object all the time ( Rotation following )
Ideas : At the beginning of the game, get the vector of the position gap with the player , Then update the position of the following object , Then change the position to the specified distance , Finally, get the gap vector .
because RotateAround You can only rotate around the target , You cannot control the radius of rotation , So you need to constantly update the position to control the radius of rotation .
The effect is as follows :
The code to follow the rotation is as follows :
using System.Collections;using System.Collections.Generic;using UnityEngine; public class Saber : MonoBehaviour { public Transform targetPos;// Rotate center object public float speed = 200f;// Rotation speed public float distance;// Radius of rotation Vector3 dir; void Start() { dir = transform.position - Target.transform.position; } void Update() { // Update the position of the following object transform.position = targetPos.position + dir.normalized * distance; // Rotate around the character transform.RotateAround(targetPos.position, Vector3.up, speed * Time.deltaTime); // Update direction vector dir = transform.position - targetPos.position; } 
边栏推荐
- 『忘了再学』Shell流程控制 — 36、for循环介绍
- 配电室环境监控系统技术方案
- i.MX - RT1052 SPI和 I2C接口
- Embedded struct and embedded interface
- i.MX - RT1052 SDCard操作(SDIO接口)
- MySQL-DDL
- What are the precautions for PCB design?
- Musk's "good friend" impacts the largest IPO of Hong Kong stocks in 2022
- Golang implements redis (9): use geohash to search people nearby
- STM32笔记之 SWJ(JTAG-DP和 SW-DP)
猜你喜欢

Snow Ice City (blackened)

i. MX - rt1052 sdcard operation (SDIO interface)
Golang implements redis (9): use geohash to search people nearby

STM32开发之 VS Code + gcc环境编译

知识点:PCB电路板的几种特殊布线方法

Rename all files in the folder with one click

Ansible 配置首次ssh免认证的操作说明

Ansible operating instructions for configuring SSH authentication free for the first time

STM32笔记之 PWM(脉宽调制)

External attention tensorflow (under update)
随机推荐
版本号命名规范
These three young men are more ruthless than Ma Huateng and Zhang Yiming
Understand UML class diagram and sequence diagram
配电室环境监控系统技术方案
STM32开发之 VS Code + gcc环境编译
Introduction to CPU, MPU, MCU, SOC and MCM
Uniapp wechat applet obtains location authorization
一文搞懂 Flink OperatorChain 对象重用
3. 函数提高
Transaction
RPC (remote procedure call protocol)
STL basic container test
记录一次pytorch训练模型遇到的报错
这3个后生,比马化腾、张一鸣还狠
华为是如何从0到1打造以项目为中心运作的项目管理体系的?
HMS Core机器学习服务身份证识别功能,实现信息高效录入
i.MX - RT1052输入输出(GPIO)
Redis maximum memory elimination strategy
简单工厂VS工厂方法&手写自动化工厂——系统学习六
Some functions used in tensorflow