- Home /
This question was
closed Jul 19, 2020 at 07:08 PM by
Anoop114.
Question by
Anoop114 · Jul 17, 2020 at 10:09 PM ·
gameobjecttransformposition
I want to move a cube with rotation but I find this problem
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerMovment : MonoBehaviour { public float speed; private Vector3 offset; public int step = 9; bool input = true; public GameObject player; public GameObject center; public GameObject right; public GameObject left;
void Update()
{
if (input == true){
if(Input.GetKey(KeyCode.RightArrow)){
StartCoroutine("moveRight");
input = false;
}
if(Input.GetKey(KeyCode.LeftArrow)){
StartCoroutine("moveleft");
input = false;
}
}
}
IEnumerator moveRight(){
for(int i = 0;i<(90/step);i++){
player.transform.RotateAround(right.transform.position,Vector3.back,step);
yield return new WaitForSeconds (speed);
}
center.transform.position = player.transform.position;
input = true;
}
IEnumerator moveleft(){
for(int i = 0;i<(90/step);i++){
player.transform.RotateAround(left.transform.position,Vector3.forward,step);
yield return new WaitForSeconds (speed);
}
center.transform.position = player.transform.position;
input= true;
}
}
screenshot-233.png
(204.9 kB)
Comment
Answer by Artik2442 · Jul 18, 2020 at 03:59 PM
Hi!
This is because you wrote "transfrorm" (there is an "r" between the "f" and the "o") and not "transform" at line 20.
Look at carefully in the error notification!