How do you translate transform (eks. down below) js>c# ?
function Update()
transform.Translate(Vector3.forward * Time.deltaTime * mySpeed);
myDist += Time.deltaTime * mySpeed;
if(myDist >= myRange)
Destroy(gameObject);
How do you translate transform (eks. down below) js>c# ?
function Update()
transform.Translate(Vector3.forward * Time.deltaTime * mySpeed);
myDist += Time.deltaTime * mySpeed;
if(myDist >= myRange)
Destroy(gameObject);
The only real difference with this code is that you need to statically define the return type of Update() in C#.
public void Update()
{
this.transform.Translate((Vector3.forward * mySpeed) * Time.deltaTime);
myDist += (mySpeed * Time.deltaTime);
if(myDist >= myRange)
{
this.Destroy(this.gameObject);
}
}
Oddly enough, that code looks to me like it should compile as-is in either JS or C# (I'd test, but I'm not at a machine with Unity installed). If you open the console log, do you see any error messages? What are you trying to do that isn't working?
– rutterI agree with @rutter. This should compile. You are missing the '{' and '}' for the Update() function. Just take the lines of code starting with 'transform.Translate()...' and past them into a new C# script.
– robertbuOk, ty guys :) :P Found out of it.
– Steff120