当前位置:网站首页>Unity关于本地坐标和世界坐标之间的转换
Unity关于本地坐标和世界坐标之间的转换
2022-06-24 19:19:00 【charlsdm】
常用的就是transformPoint这一类的API引用了
下面附上我写的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreateCube : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
[ContextMenu("左前方创建空物体")]
void TestFun1()
{
// Vector3 pos = this.transform.TransformPoint(new Vector3(-1, 0, 1));
GameObject obj = new GameObject("hello");
obj.transform.position = this.transform.TransformPoint(new Vector3(-1, 0, 1));
}
[ContextMenu("勉强创建3个球体")]
void TestFun2()
{
GameObject objOne = GameObject.CreatePrimitive(PrimitiveType.Sphere);
objOne.transform.position = this.transform.TransformPoint(new Vector3(0, 0, 1));
GameObject objTwo = GameObject.CreatePrimitive(PrimitiveType.Sphere);
objTwo.transform.position = this.transform.TransformPoint(new Vector3(0, 0, 2));
GameObject objThree = GameObject.CreatePrimitive(PrimitiveType.Sphere);
objThree.transform.position = this.transform.TransformPoint(new Vector3(0, 0, 3));
}
}
边栏推荐
- Realization of truth table assignment by discrete mathematical programming
- Dynamic routing protocol rip, OSPF
- memcached全面剖析–3. memcached的删除机制和发展方向
- Packaging_ Conversion between basic type and string type
- The first day of handwritten RPC -- review of some basic knowledge
- Football information query system based on C language course report + project source code + demo ppt+ project screenshot
- Golang reflection operation collation
- Create a multithreaded thread class
- Pod lifecycle in kubernetes
- Alibaba cloud lightweight servers open designated ports
猜你喜欢
EditText 控制软键盘出现 搜索
Adding subscribers to a list using mailchimp's API V3
Auto. JS to automatically authorize screen capture permission
B站带货当学新东方
浅谈MySql update会锁定哪些范围的数据
Concepts of kubernetes components
How Fiddler works
Common data model (updating)
memcached完全剖析–1. memcached的基础
Network security review office starts network security review on HowNet
随机推荐
OSI notes sorting
I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world
Several common command operations in win system
Realization of truth table assignment by discrete mathematical programming
Pyaudio audio recording
Common self realization functions in C language development
Logical backup: mysqldump vs physical backup: xtrabackup
Read all text from stdin to a string
Summary of idea practical skills: how to rename a project or module to completely solve all the problems you encounter that do not work. It is suggested that the five-star collection be your daughter
JMeter parameterization
Requests requests for web page garbled code resolution
浅谈MySql update会锁定哪些范围的数据
regular expression
After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked
Handwritten RPC the next day -- review of some knowledge
Simple analysis of WordPress architecture
Power apps Guide
Reflect package
Dynamic routing protocol rip, OSPF
Axi DMA IP core operation process