炳传更新

系统更新

人物控制

人物控制方式更改

版本内容
前传2d人物rpg走格子
番外传统wasd控制人物走动,停止按键之后人物同时停止运动。
新作wasd控制人物方向,采用绝对坐标轴,停止按键之后人物不会停止,会按照面向的方向一直走动,直到碰到block停止。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class charaMove : MonoBehaviour {
	public float speed = 4;
	public float rotSpeed = 12;
	int x;
	int z;

	Vector3 targetPos;
	public Vector3 vet= new Vector3(0,0,0);
	Vector3 vetStop= new Vector3(0,0,0);
	Vector3 oldVet= new Vector3(0,0,0);

	void Update () {
		if (Input.GetKey (KeyCode.A)) 
		vet = Vector3.left;
		if (Input.GetKey (KeyCode.D))
		vet = Vector3.right;
		if (Input.GetKey (KeyCode.W)) 
		vet = Vector3.forward;
		if (Input.GetKey (KeyCode.S)) 
		vet = Vector3.back;
		if (!(vet == vetStop)) {
			oldVet = vet;
			transform.Translate (oldVet * Time.deltaTime * speed, Space.World);
			if (oldVet==Vector3.left||oldVet==Vector3.right) {
				targetPos = new Vector3 (transform.position.x, transform.position.y, Mathf.RoundToInt (transform.position.z));
			
				transform.position = Vector3.Lerp (transform.position, targetPos, 0.4f);
			}
			if (oldVet==Vector3.forward||oldVet==Vector3.back) {
				targetPos = new Vector3 (Mathf.RoundToInt (transform.position.x), transform.position.y, transform.position.z);
				transform.position = Vector3.Lerp (transform.position, targetPos, 0.4f);
			}
			vetStop = Vector3.zero;
		}
		Rotating (oldVet);
	}
	void Rotating(Vector3 targetDir)	{//change rotation by Lerp
		if (!(targetDir == Vector3.zero)) {
			Quaternion targetRot = Quaternion.LookRotation (targetDir, Vector3.up);
			transform.rotation = Quaternion.Lerp (transform.rotation, targetRot, speed * Time.deltaTime * 4);
		}
	}

	void forWard(Vector3 targetFor, Vector3 oldTar){//change forward
		if(!(oldTar ==targetFor)){
			int x = Mathf.RoundToInt (transform.position.x);
			int z = Mathf.RoundToInt (transform.position.z);
			Vector3 targetPos = new Vector3 (x, transform.position.y, z);
			transform.position =Vector3.Lerp(transform.position,targetPos,0.01f);
		}
	}
	void  OnTriggerStay(Collider collider){
		if (collider.tag == "Block") {
			int x = Mathf.RoundToInt (transform.position.x);
			int z = Mathf.RoundToInt (transform.position.z);
			
			Vector3  target = new Vector3 (x,transform.position.y,z);
			transform.position = Vector3.Lerp (transform.position, target, 0.4f);
			this.vetStop = this.vet;
		}
	}
}

摄像头控制

更新了摄像头跟踪算法,优化了在高建筑的视角跟踪
在高墙边上摄像头不容易被建筑物遮挡
在高墙边上摄像头不容易被建筑物遮挡

建筑更新

更新了学院教学楼外设
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值