[ASK]error cs0029 , help me please :(
2 posters
Page 1 of 1
[ASK]error cs0029 , help me please :(
tolong saya para master, saya newbie sedang belajar ,
saya mempunyai maslah dengan coding ini
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
CharacterController _controller;
// Use this for initialization
void Start () {
_controller = GetComponents<CharacterController>();
}
// Update is called once per frame
void Update () {
Vector3 direction = new Vector3 (Input.GetAxis("horizontal"), 0, Input.GetAxis("vertical"));
_controller.Move (direction);
}
}
ketika saya mau coba play , muncul error gini "error CS0029: Cannot implicitly convert type `UnityEngine.CharacterController[]' to `UnityEngine.CharacterController' " , tolong saya apanya yang salah ???
saya mempunyai maslah dengan coding ini
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
CharacterController _controller;
// Use this for initialization
void Start () {
_controller = GetComponents<CharacterController>();
}
// Update is called once per frame
void Update () {
Vector3 direction = new Vector3 (Input.GetAxis("horizontal"), 0, Input.GetAxis("vertical"));
_controller.Move (direction);
}
}
ketika saya mau coba play , muncul error gini "error CS0029: Cannot implicitly convert type `UnityEngine.CharacterController[]' to `UnityEngine.CharacterController' " , tolong saya apanya yang salah ???

fitrah68- Unity3D Newbie
- Posts : 2
Points : 4
Reputation : 0
Join date : 2015-04-23
Re: [ASK]error cs0029 , help me please :(
Bedakan lho GetComponent dan GetComponents...
Unity bingung,
kalo mau akses komponen lebih dari satu pake GetComponents,
seharusnya variabelnya dalam bentuk array (pake tanda kurung kotak [] )
Sedangkan yang mau agan akses kan cuma satu komponen,
maka tulisan GetComponents coba dirubah jadi GetComponent
Unity bingung,
kalo mau akses komponen lebih dari satu pake GetComponents,
seharusnya variabelnya dalam bentuk array (pake tanda kurung kotak [] )
Sedangkan yang mau agan akses kan cuma satu komponen,
maka tulisan GetComponents coba dirubah jadi GetComponent

black pigeon- Unity3D Newbie
- Posts : 56
Points : 64
Reputation : 6
Join date : 2013-03-04
Re: [ASK]error cs0029 , help me please :(
owh iya bener , saya nggak ngeh itu ,,,
trima kasih banyak om ..
trima kasih banyak om ..

fitrah68- Unity3D Newbie
- Posts : 2
Points : 4
Reputation : 0
Join date : 2015-04-23
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
» [ASK HELP] Slide informasi di augmented reality
» ASK cara klik dan memunculkan informasi
» [Ask] mengubah game PC menjadi game Android
» Virtualisasi suatu Gedung mengunakan unity3D + google seketchUP
» Minta Tolong, slideshow ngga muncul saat object di klik
» tolong dong lagi bikin button rotate tp button ga keluar
» algoritma Minimax/negascout buat checkers
» screenshot