当前位置:网站首页>[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; } 
边栏推荐
- MySQL-DML
- SDCC编译器 + VSCode开发 8位微控制器
- i. MX - rt1052 SPI and I2C interfaces
- [comprehensive pen test] difficulty 2.5/5: "tree array" and "double tree array optimization"
- Musk's "good friend" impacts the largest IPO of Hong Kong stocks in 2022
- Sdcc compiler + vscode to develop 8-bit microcontroller
- [deep learning] use deep learning to monitor your girlfriend's wechat chat?
- Redis-bitmap 位图
- RPC(远程过程调用协议)
- 2. 数据类型
猜你喜欢

Jenkins 通过Build periodically配置定时任务

Apache shardingsphere 5.1.2 release | new driving API + cloud native deployment to create a high-performance data gateway

Summary of UART problems in stm32cubemx

External attention tensorflow (under update)

i.MX - RT1052输入输出(GPIO)

The wechat authorization login window will pop up automatically

这3个后生,比马化腾、张一鸣还狠

Hands on data analysis data reconstruction

Sdcc compiler + vscode to develop 8-bit microcontroller

STM32开发之 VS Code + GDB下载调试
随机推荐
Redis个人总结简洁版
第八章 Web项目测试
7. 指针
Redis personal summary concise version
看懂UML类图和时序图
『忘了再学』Shell流程控制 — 36、for循环介绍
Vs code + GDB download and debugging of STM32 development
findpanel的相关代码
Apache shardingsphere 5.1.2 release | new driving API + cloud native deployment to create a high-performance data gateway
Hands on data analysis data visualization
Standing at the digital tuyere, how can tooling enterprises "fly"
i.MX - RT1052时钟及锁相环(PLL)分析
方法的繼承和重寫
UML的六种关系-系统学习四
Vs code + GCC environment compilation for STM32 development
4. 程序流程结构
2. 引用
i. MX - rt1052 boot start
马斯克的“好朋友”,冲击2022港股最大IPO
五大(七大)原则-系统学习三