元宇宙是一个平行于现实世界,又独立于现实世界的虚拟空间,是映射现实世界的在线虚拟世界,是越来越真实的数字虚拟世界。而区块链是采用分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。
区块链和元宇宙,一个象征极简自由的去中心化技术,一个代表互联网未来的新概念,两者会有什么联系呢?
我们现在所看到的元宇宙,并不仅仅只是包含了区块链技术,还包含了VR/AR技术、人工智能技术等诸多技术门类。
从本质上来看,元宇宙是一种新的数据传输方式的开始。它实现了现实世界和虚拟世界之间数据传输的双向自由流动,构建了一个不完全相同于物理现实的虚拟世界。
数据传输的自由流动是虚拟世界与现实世界融合、实物资产与数字资产对接的前提和基础。
关键代码如下:
public class RobotManager:MonoBehaviour
{
private Animator _animator;
private Rigidbody _rigidbody;
private CharacterController _characterController;
private Transform _transform;
public float Yaw{get;private set;}
public float jumpHeight=2.0f;
public float walkSpeed=3.0f;
public float mouseSensitivity=10;
public Photographer photographer;
public Scrollbar mouseSensitivityScrollbar;
public Scrollbar speedScrollbar;
public Scrollbar jumpHeightScrollbar;
//Start is called before the first frame update
public void setYaw(float yaw,float mouseX)
{
Yaw=yaw;
_transform.rotation=Quaternion.Euler(0,Yaw,0);
_animator.SetFloat("Direction",mouseX);
}
public void mouseSensitivityScrollbarChanged()
{
mouseSensitivity=mouseSensitivityScrollbar.value*20;
}
public void speedScrollbarChanged()
{
walkSpeed=speedScrollbar.value*6;
}
public void jumpHeightScrollbarChanged()
{
jumpHeight=jumpHeightScrollbar.value*4;
}
private void Awake()
{
_animator=GetComponent<Animator>();
_characterController=GetComponent<CharacterController>();
_rigidbody=GetComponent<Rigidbody>();
_transform=GetComponent<Transform>();
}
//Update is called once per frame
void Update()
{
float x=Input.GetAxis("Mouse X")*mouseSensitivity;
float y=Input.GetAxis("Mouse Y")*mouseSensitivity;
Yaw+=x;
photographer.SetYaw(Yaw);
_transform.rotation=Quaternion.Euler(0,Yaw,0);
_animator.SetFloat("Direction",x);
float h=Input.GetAxis("Horizontal");
float v=Input.GetAxis("Vertical");
float j=Input.GetAxis("Jump");
Quaternion rot=Quaternion.Euler(0,Yaw,0);
Vector3 CurrentInput=vVector3.forward+hVector3.right;
CurrentInput=walkSpeed(rotVector3.ClampMagnitude(CurrentInput,1))+
jumpHeightjVector3.up;
//_transform.Translate(Time.fixedDeltaTime*CurrentInput);
_rigidbody.MovePosition(_rigidbody.position+Time.fixedDeltaTime*CurrentInput);
//Debug.Log("x:"+_rigidbody.position.x+",y:"+_rigidbody.position.y+",z:"+_rigidbody.position.z);
_animator.SetFloat("Speed",v);
}
}