Referencing a script from another object always throws me up a line error in the form of a tantrum
GameObject.Find("simplePlayer").GetComponent(vp_FPController).enabled = true ();
Basicly calling the coponent this way throws me the error “is a type used like a variable”
so how excactly do i call this component from another object???
On top of this i havnt used courtines in a while, i used them before to create a spawn transition of my character
transforming from one object to another with a particle animation playing between the time. but i cant find much information on using them and dont have the project anymore to reference the code for setting time periods.
If anyone could help me with either both or one segmant of this post would help aleeve my tantrum
Kind Regards
Chris
I may come back to this post with regard to the second part… For now, the first part.
// bracket type changed and '()' removed from the end, after 'true'.
// Find isn't great if you can find an alternative, like linking it in the inspector, but anyways, separate issue. :)
GameObject.Find("simplePlayer").GetComponent<vp_FPController>.enabled = true;
note: I do not know for certain if the brackets’ change actually matters, but that’s the way I always write it, so just made sense to me, and in case
The part at the end was surely incorrect in your first post.
1 Like
Still looking for help on a CoRoutine to do something?
Its ok man i found my old mutation script prototype. Just gonna use it as an example like i did before. Ill post it bellow just incase you wanna add some tasty tricks. Cheers for your help man
using UnityEngine;
using System.Collections;
public class Mutate : MonoBehaviour {
public GameObject Normal; // Set Original Character
public GameObject Mutation; // Set Mutated Character
public GameObject ParticleEffect1; // Set Particle effects for change
public GameObject ParticleEffect2; // Set Particle effects for change
public GameObject ParticleEffect3; // Set Particle effects for change
public float TransformDuration = 4; //only change how many seconds in inspector
public float ParticleEffectDuration = 2;
public float PauseDuration = 1;
public int startingHealth = 100;
void start ()
{
}
// Update is called once per frame
void Update ()
{
{
if (Input.GetKeyDown ("e"))
ParticleEffect2.SetActive(true);
if (Input.GetKeyDown ("e"))
ParticleEffect1.SetActive(true);
if (Input.GetKeyDown ("e"))
Normal.SetActive(false);
if (Input.GetKeyDown ("e"))
StartCoroutine (LateCall ());
}
}
IEnumerator LateCall()
{
yield return new WaitForSeconds (TransformDuration);
Mutation.SetActive(true);
yield return new WaitForSeconds (PauseDuration);
ParticleEffect1.SetActive(false);
yield return new WaitForSeconds (PauseDuration);
ParticleEffect2.SetActive(false);
yield return new WaitForSeconds (PauseDuration);
Mutation.GetComponent<Animation>().Play ("spawn");
}
}
Other than having 4 statements asking if the same key was pressed lol, it looks all okay. Glad ya found it.
If the CoRoutine is expected to be triggered often, there is a small performance tip that you can utilize where you cache the “new WaitForSeconds”.
All in all it’s all good. Don’t know any tricks for ya on this 