Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Receiving the error code: CS0029: Cannot implicitly convert type `UnityEngine.Vector3' to `int'

$
0
0
using UnityEngine; using System.Collections; public class RollBlock : MonoBehaviour { private Transform parent; private Vector3[] dirs = new Vector3[Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back]; float speed= 90.0f; static bool inputEnabled= true; void Start (){ parent = new GameObject().transform; } void Update (){ if (Input.GetKeyDown(KeyCode.LeftArrow)) { if(inputEnabled){ FlopTheBlock(Vector3.left); inputEnabled = false; StartCoroutine(PauseForSeconds()); } } else if (Input.GetKeyDown(KeyCode.RightArrow)) { if(inputEnabled){ FlopTheBlock(Vector3.right); inputEnabled = false; StartCoroutine(PauseForSecondss()); } } else if (Input.GetKeyDown(KeyCode.UpArrow)) { if(inputEnabled){ FlopTheBlock(Vector3.forward); inputEnabled = false; StartCoroutine(PauseForSecondss()); } } else if (Input.GetKeyDown(KeyCode.DownArrow)) { if(inputEnabled){ FlopTheBlock(Vector3.back); inputEnabled = false; StartCoroutine(PauseForSecondss()); } } } IEnumerator FlopTheBlock ( Vector3 direction ){ float down= WhatsDown(); float dir= transform.InverseTransformDirection(direction); float pos= dir * 0.5f + down * 0.5f; pos = transform.TransformPoint(pos); Vector3 axis= Vector3.Cross(Vector3.down, direction); transform.parent = null; parent.rotation = Quaternion.identity; parent.position = pos; transform.parent = parent; Vectore3 qTo= Quaternion.AngleAxis(-90.0f, axis); while (parent.rotation != qTo) { parent.rotation = Quaternion.RotateTowards(parent.rotation, qTo, speed * Time.deltaTime); yield return 0; } } Vector3 WhatsDown (){ for (int i= 0; i < dirs.Length; i++) { if (Vector3.Dot(transform.TransformDirection(dirs[i]), Vector3.down) > 0.9f) return dirs[i]; } } IEnumerator pauseForSeconds (){ yield return new WaitForSeconds(.25f); inputEnabled = true; } } I'm converting this code from UnityScript to CSharp and I'm getting this error. What is wrong with the code? I've been looking into this all day and can't figure it out.

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>