- Home /
Unity Steer, C# to UnityScript
Hi, I have been using unity script for about 4 months and I just downloaded the Unity steer package. I need a script that changes just one variable in another code. In UnityScript it would look like this
function Update () {
target = GetClosestObject("Mantis");
GetComponent(typeof(SteerForPursuit)).GetTarget(target);
etc
and on the affected object:
function GetTarget(target:GameObject){
Quarry=target;
}
But after a few days of studying how to translate that into C#, I've come up blank on a translation.
Any help would be greatly appreciated. Thank you!
Is it the GetComponent() you are having trouble with? One way:
GetComponent< SteerForPursuit >().GetTarget(target);
Tahnks!!!!! it worked, I guess I just need a hand in the Get component thingy
Answer by Ashkan_gc · May 20, 2013 at 06:25 PM
When you use typeof in GetComponent in C# then you should cast the result from object to SteerForPursuit like this (GetComponent(typeof(SteerForPursuit)) as SteerForPursuit).GetTarget()//anything
But the generic version with does not require it as you can see.
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
EnemyAI C# Error 1 Answer
AI positioning in soccer game 1 Answer
C# Script Not Working? 2 Answers