void RotAin()
{
int x = 1;
if (x==1)
{
gameObject.transform.position = new Vector3(transform.rotation.w, transform.rotation.w, gameObject.transform.position.z);
x++;
}
else
{
gameObject.transform.position = new Vector3(transform.rotation.w, gameObject.transform.rotation.y, gameObject.transform.position.z);
}
}
void RotAin()
- вызываю в Update if(Input.GetKey(KeyCode.D))
{
tempPos.z = tempPos.z * speed * Time.deltaTime;//изменяем позицию игрока
Newpos = tempPos.z;
hero.transform.position =
Vector3.MoveTowards(transform.position, //Переместить из текущего положения
new Vector3(hero.transform.position.x,hero.transform.position.y,Newpos)/*нам нужно изменить только x координату*/ , speed); //перемещаем игрока в новую позицию
}