- Home /
Question by
mrnee · Jan 07, 2013 at 09:17 PM ·
c#javascriptnetworking
Please, help me translating these to C#
PhotonNetwork.Instantiate
didn't work in JS. And there is no Scripting reference for C# (CodeAcademy noob here)
Here are two scripts
var speed = 3.0;
var sifaPrefab:Transform;
function Update ()
{
// find out if button is pressed
if(Input.GetButtonDown("Fire1"))
{
//check if has ammo
if (collisions.SIFA_AMMO >0)
{
//create the prefab
var sifa = Instantiate(sifaPrefab, transform.position, Quaternion.identity);
// toss prefab
sifa.rigidbody.AddForce(transform.forward * 2000);
//remove ammo
collisions.SIFA_AMMO -=1;
print ("sifa dropped!");
}
}}
second script
static var SIFA_AMMO=0;
function OnControllerColliderHit(hit : ControllerColliderHit)
{
//check if colliding object is sifa
if (hit.gameObject.tag == "sifa")
{
// destroy sifa
Destroy(hit.gameObject);
// add sifa to the inventory
if (SIFA_AMMO == 0)
{
SIFA_AMMO +=1;
print ("SIFA PICKED UP!");
}
}
}
Comment
Best Answer
Answer by liszto · Jan 07, 2013 at 10:40 PM
A fast transcript here : http://pastebin.com/PcQ1uF7M
Don't forget to put this in a new script because in C# script you need a class to contain all others functions ;)
Your answer
Follow this Question
Related Questions
Online Player Position 1 Answer
Multiple Cars not working 1 Answer
how to use the listen port in this case? 0 Answers
Distribute terrain in zones 3 Answers
I need help translating Javascript to C# 0 Answers