Question by
Chaoz64 · Aug 11, 2017 at 11:30 PM ·
programmingstringintproblem during runtime
Need help with a code!!
I made an script in c# and it told me this. "The best overlapping method overload for 'UnityEngine.Animation.this [string]' has some non-valid arguments" and then this "Can't be converted from 'int' to 'string' " in monodevelop, I don't know what to do, can some one help me?.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MysteryBox : MonoBehaviour {
Animator controller;
Animation movement;
public bool openBox;
// Use this for initialization
void Start () {
controller = GetComponentsInChildren<Animator>()[0];
movement = GetComponentInChildren<Animation> () [0];
}
// Update is called once per frame
void Update () {
if (openBox)
{
OpenMysteryBox ();
}
}
void OpenMysteryBox()
{
OpenLid ();
RunGunMovement ();
}
void OpenLid()
{
controller.Play ("OpenLid");
}
void CloseLid()
{
controller.Play ("CloseLid");
}
void RunGunMovement()
{
movement.Play ();
}
}
The problem it's in the part that says: "movement = GetComponentInChildren () [0];"}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MysteryBox : MonoBehaviour {
Animator controller;
Animation movement;
public bool openBox;
// Use this for initialization
void Start () {
controller = GetComponentsInChildren<Animator>()[0];
movement = GetComponentInChildren<Animation> () [0];
}
Comment
Your answer
Follow this Question
Related Questions
Word guessing game 1 Answer
Player rapidly stutters back and forth while moving 0 Answers
C# Having troubles with creating/referencing a random list. 1 Answer
2 touch Destroy(gameObject); 2 Answers