Inheritance: Component
Esempio n. 1
0
	// Use this for initialization
	void Start () {

		//Get a component reference to the Character's animator component
		animator = GetComponent<Animator>();
		render = GetComponent<SpriteRenderer>();

		//Get the rigid body on the prefab
		bullBody = GetComponent<Rigidbody2D>();

		//Set our bullet strength and speed
		strength = 4;
		speed = 40;

		//Go after our player!
		player = GameObject.Find("Player").GetComponent<Player>();

		//Get our Player current Direction
		if (player.getDirection () > 0 ||
			(player.getDirection() == 0 && player.getLastDirection() > 0 )) {
			animator.SetInteger ("Direction", 1);
			playerRight = true;
		} else {
			playerRight = false;
			animator.SetInteger ("Direction", -1);
		}

		//Play our shooting sound
		shoot = GameObject.Find ("Shoot").GetComponent<AudioSource> ();

			shoot.Play ();

		//Get our camera script
		actionCamera = Camera.main.GetComponent<ActionCamera>();
	}
 void Start()
 {
     levelClock = GameObject.Find("gameBase").GetComponent<levelClock>();
     spaceship = GameObject.Find("spaceship");
     rb = spaceship.GetComponent<Rigidbody2D>();
     body = spaceship.GetComponent<Transform>();
 }
Esempio n. 3
0
    void Start()
    {
        transform = GetComponent<Transform> ();
        rb = GetComponent<Rigidbody2D> ();

        player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Rigidbody2D> ();
    }
Esempio n. 4
0
 // Use this for initialization
 void Start()
 {
     if (playerNum == 0){
         Debug.LogError("set playernum for" + gameObject.name);
     }
     r = GetComponent<Rigidbody2D>();
 }
 // Use this for initialization
 void Start()
 {
     target = GameObject.FindGameObjectWithTag ("Player");
     temp = GetComponent<Rigidbody2D> ();
     GetComponent<Animator> ().SetBool ("punching", true);
     playerHealth = GameObject.FindGameObjectWithTag ("PlayerHealth");
 }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        target = GameObject.Find ("player").transform;
        rb = GetComponent<Rigidbody2D>();

        direction = ((Vector2)(target.position - transform.position)).normalized * 30;
    }
Esempio n. 7
0
 // Use this for initialization
 void Start()
 {
     //Hämtar bara referenser 1 gång, GetComponent är väldigt långsam!!!
     rb2d = GetComponent<Rigidbody2D>();
     anim = GetComponent<Animator>();
     ps = GetComponent<ParticleSystem>();
 }
Esempio n. 8
0
	// Update is called once per frame
	void FixedUpdate () {
		if(testItem.testValue3 && stop.controlF == 1)
		{
			itemC = (Rigidbody2D)Instantiate(item, transform.position, transform.rotation);
		}
		
	}
	// Use this for initialization
	void Start () {
		rbd2D = GetComponent<Rigidbody2D> ();
		anim = GetComponent<Animator> ();
		aL = (Arrow_Launch)FindObjectOfType (typeof(Arrow_Launch));
		directEnemy = (Enemy_Controller)FindObjectOfType (typeof(Enemy_Controller));
		pStatus = (Player_Status)FindObjectOfType (typeof(Player_Status));
	}
Esempio n. 10
0
	// Use this for initialization
	void Start () {
        rb = GetComponent<Rigidbody2D>();
        sr = GetComponent<SpriteRenderer>();
        limits = Camera.main.ViewportToWorldPoint(Vector3.right).x -
            HalfWidth;
        time = shootTime;
    }
Esempio n. 11
0
 void Start()
 {
     instance = this;
     gameStart = false;
     r2d = GetComponent<Rigidbody2D>();
     consecutivePaddleHits = consecutiveWallHits = 0;
 }
Esempio n. 12
0
    protected virtual void FixedUpdate()
    {
        if (rigidbody2d == null) rigidbody2d = GetComponent<Rigidbody2D>();

        Velocity        = rigidbody2d.velocity;
        AngularVelocity = rigidbody2d.angularVelocity;
    }
Esempio n. 13
0
 void Awake()
 {
     Object.DontDestroyOnLoad(gameObject);
     rb = gameObject.GetComponent<Rigidbody2D> ();
     Application.LoadLevel (1);
     inEndSequence = false;
 }
 void Awake()
 {
     Transform canvas = transform.Find("Canvas");
     Group = canvas.GetComponent<CanvasGroup>();
     Text = canvas.Find("Text").GetComponent<Text>();
     Rigidbody = GetComponent<Rigidbody2D>();
 }
Esempio n. 15
0
 // Use this for initialization
 void Start()
 {
     rockGet = GetComponent<AudioSource>();
     rb = GetComponent<Rigidbody2D>();
     playerScore = 0;
     Moving = true;
 }
 void Awake()
 {
     sprite = GetComponent<SpriteRenderer>();
     body = GetComponent<Rigidbody2D>();
     col = GetComponent<BoxCollider2D>();
     parentBalista = transform.parent.gameObject;
 }
Esempio n. 17
0
	// Use this for initialization
	void Start () {

		//必要な情報の取得 
		rigid = GetComponent<Rigidbody2D>();
		sprite = GetComponent<SpriteRenderer>();
		
	}
    private bool m_FacingRight = true;  // For determining which way the player is currently facing.

    private void Awake() {
        // Setting up references.
        m_GroundCheck = transform.Find("GroundCheck");
        m_CeilingCheck = transform.Find("CeilingCheck");
        m_Anim = GetComponent<Animator>();
        m_Rigidbody2D = GetComponent<Rigidbody2D>();
    }
Esempio n. 19
0
	void Init(){
		Player = GameObject.FindGameObjectWithTag("Player");
		direction = Player.GetComponent<Player_Control>().VecDirection;
		rb = gameObject.GetComponent<Rigidbody2D>();
		rb.AddForce(direction*moveSpeed);

	}
Esempio n. 20
0
	// Use this for initialization
	void Start () {

        myTransform = transform;
        originalPosition = myTransform.position;
        rigidBody = GetComponent<Rigidbody2D>();
	
	}
Esempio n. 21
0
 // Use this for initialization
 void Start()
 {
     this.player = PlayerController.instance;
     this.rb2d = this.GetComponent<Rigidbody2D> ();
     this.melee = this.GetComponent<MeleeAttacker> ();
     this.animator = this.GetComponent<Animator> ();
 }
Esempio n. 22
0
 void Awake()
 {
     rb2d = GetComponent<Rigidbody2D>();
     anim = GetComponent<Animator>();
     aud = GetComponent<AudioSource>();
     jps = transform.GetChild(2).GetComponent<ParticleSystem>();
 }
Esempio n. 23
0
	// Use this for initialization
    void Start()
    {
        rigid = GetComponent<Rigidbody2D>();
        box = GetComponent<BoxCollider2D>();
        esperando = espera;
        anim = GetComponent<Animator>();
	}
Esempio n. 24
0
    protected virtual void OnDestructibleSplit(D2D_SplitData splitData)
    {
        if (rigidbody2d == null) rigidbody2d = GetComponent<Rigidbody2D>();

        rigidbody2d.velocity        = Velocity;
        rigidbody2d.angularVelocity = AngularVelocity;
    }
Esempio n. 25
0
    public Vector3 getSteering(Rigidbody2D target, ICollection<Rigidbody2D> obstacles, out Vector3 bestHidingSpot)
    {
        //Find the closest hiding spot
        float distToClostest = Mathf.Infinity;
        bestHidingSpot = Vector3.zero;

        foreach(Rigidbody2D r in obstacles)
        {
            Vector3 hidingSpot = getHidingPosition(r, target);

            float dist = Vector3.Distance(hidingSpot, transform.position);

            if(dist < distToClostest)
            {
                distToClostest = dist;
                bestHidingSpot = hidingSpot;
            }
        }

        //If no hiding spot is found then just evade the enemy
        if(distToClostest == Mathf.Infinity)
        {
            return evade.getSteering(target);
        }

        //Debug.DrawLine(transform.position, bestHidingSpot);

        return steeringBasics.arrive(bestHidingSpot);
    }
Esempio n. 26
0
 void Start()
 {
     ThisBody = GetComponent<Rigidbody2D>();
     Anim = GetComponent<Animator>();
     TailLight = Light.GetComponent<Light>();
     // SpriteRen = GetComponent<SpriteRenderer>();
 }
 // Use this for initialization
 void Start()
 {
     this.koopaShellScript = this.transform.parent.GetComponent<KoopaShellScript> ();
     this.player = GameObject.FindWithTag ("Player");
     this.playerScript = this.player.GetComponent<PlayerScript>();
     this.playerRb = this.player.GetComponent<Rigidbody2D>();
 }
Esempio n. 28
0
    // Use this for initialization
    void Start()
    {
        cameraRigidbody = GetComponent<Rigidbody2D> ();
        cameraRigidbody.gravityScale = 0;

        //lastPosition = player.transform.position;
    }
Esempio n. 29
0
    void Awake()
    {
        this.rigidBody = this.GetComponent<Rigidbody2D>();
        this.rigidBody.isKinematic = true;

        this.IsActive = false;
    }
Esempio n. 30
0
    public override void FireAbility()
    {
        playerBody = getRootComponent().rigidbody2D;

        int layerMask = 0;
        Vector3 direction = Vector3.down;

        if (IsArm)
        {
            grappleableLayers.ForEach(l => layerMask |= 1 << LayerMask.NameToLayer(l));
            direction = forward.position - transform.position;
            direction.Normalize();
        }
        else // leg
        {
            legClampLayers.ForEach(l => layerMask |= 1 << LayerMask.NameToLayer(l));
        }

        if (!fired)
        {
            // Fire it like a projectile, until it hits something...
            projectile.FireProjectile(direction * projectileVelocity + playerBody.velocity.XY0(), layerMask);

            SFXSource.PlayOneShot(fireClip);

            // TODO - what about grabbing objects?

            fired = true;
            spriteRenderer.sprite = firedSprite;
        }
        else
        {
            RetractGrapple();
        }
    }
 static public int Distance(IntPtr l)
 {
     try {
         UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l);
         UnityEngine.Collider2D  a1;
         checkType(l, 2, out a1);
         var ret = self.Distance(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 32
0
 static public int GetRelativePointVelocity(IntPtr l)
 {
     try{
         UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l);
         UnityEngine.Vector2     a1;
         checkType(l, 2, out a1);
         UnityEngine.Vector2 ret = self.GetRelativePointVelocity(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Esempio n. 33
0
 static void Rigidbody2D_angularVelocity(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Rigidbody2D _this = (UnityEngine.Rigidbody2D)vc.csObj;
         var result = _this.angularVelocity;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single           arg0  = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.Rigidbody2D _this = (UnityEngine.Rigidbody2D)vc.csObj;
         _this.angularVelocity = arg0;
     }
 }
 static public int GetRelativePointVelocity(IntPtr l)
 {
     try {
         UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l);
         UnityEngine.Vector2     a1;
         checkType(l, 2, out a1);
         var ret = self.GetRelativePointVelocity(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 35
0
 static void Rigidbody2D_collisionDetectionMode(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Rigidbody2D _this = (UnityEngine.Rigidbody2D)vc.csObj;
         var result = _this.collisionDetectionMode;
         JSApi.setEnum((int)JSApi.SetType.Rval, (int)result);
     }
     else
     {
         UnityEngine.CollisionDetectionMode2D arg0 = (UnityEngine.CollisionDetectionMode2D)JSApi.getEnum((int)JSApi.GetType.Arg);
         UnityEngine.Rigidbody2D _this             = (UnityEngine.Rigidbody2D)vc.csObj;
         _this.collisionDetectionMode = arg0;
     }
 }
 static public int GetAttachedColliders(IntPtr l)
 {
     try {
         UnityEngine.Rigidbody2D  self = (UnityEngine.Rigidbody2D)checkSelf(l);
         UnityEngine.Collider2D[] a1;
         checkArray(l, 2, out a1);
         var ret = self.GetAttachedColliders(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 37
0
 static void Rigidbody2D_simulated(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Rigidbody2D _this = (UnityEngine.Rigidbody2D)vc.csObj;
         var result = _this.simulated;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean          arg0  = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.Rigidbody2D _this = (UnityEngine.Rigidbody2D)vc.csObj;
         _this.simulated = arg0;
     }
 }
Esempio n. 38
0
 static void Rigidbody2D_velocity(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Rigidbody2D _this = (UnityEngine.Rigidbody2D)vc.csObj;
         var result = _this.velocity;
         JSApi.setVector2S((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Vector2     arg0  = (UnityEngine.Vector2)JSApi.getVector2S((int)JSApi.GetType.Arg);
         UnityEngine.Rigidbody2D _this = (UnityEngine.Rigidbody2D)vc.csObj;
         _this.velocity = arg0;
     }
 }
Esempio n. 39
0
 static void Rigidbody2D_constraints(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Rigidbody2D _this = (UnityEngine.Rigidbody2D)vc.csObj;
         var result = _this.constraints;
         JSApi.setEnum((int)JSApi.SetType.Rval, (int)result);
     }
     else
     {
         UnityEngine.RigidbodyConstraints2D arg0  = (UnityEngine.RigidbodyConstraints2D)JSApi.getEnum((int)JSApi.GetType.Arg);
         UnityEngine.Rigidbody2D            _this = (UnityEngine.Rigidbody2D)vc.csObj;
         _this.constraints = arg0;
     }
 }
Esempio n. 40
0
 static void Rigidbody2D_interpolation(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Rigidbody2D _this = (UnityEngine.Rigidbody2D)vc.csObj;
         var result = _this.interpolation;
         JSApi.setEnum((int)JSApi.SetType.Rval, (int)result);
     }
     else
     {
         UnityEngine.RigidbodyInterpolation2D arg0 = (UnityEngine.RigidbodyInterpolation2D)JSApi.getEnum((int)JSApi.GetType.Arg);
         UnityEngine.Rigidbody2D _this             = (UnityEngine.Rigidbody2D)vc.csObj;
         _this.interpolation = arg0;
     }
 }
Esempio n. 41
0
// fields

// properties
    static void Joint2D_connectedBody(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.Joint2D _this = (UnityEngine.Joint2D)vc.csObj;
            var result = _this.connectedBody;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.Rigidbody2D arg0  = (UnityEngine.Rigidbody2D)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Joint2D     _this = (UnityEngine.Joint2D)vc.csObj;
            _this.connectedBody = arg0;
        }
    }
Esempio n. 42
0
 static public int OverlapCollider(IntPtr l)
 {
     try {
         UnityEngine.Rigidbody2D     self = (UnityEngine.Rigidbody2D)checkSelf(l);
         UnityEngine.ContactFilter2D a1;
         checkValueType(l, 2, out a1);
         UnityEngine.Collider2D[] a2;
         checkType(l, 3, out a2);
         var ret = self.OverlapCollider(a1, a2);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 43
0
    static int get_otherRigidbody(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Collision2D obj = (UnityEngine.Collision2D)o;
            UnityEngine.Rigidbody2D ret = obj.otherRigidbody;
            ToLua.PushSealed(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index otherRigidbody on a nil value"));
        }
    }
    static int get_attachedRigidbody(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Collider2D  obj = (UnityEngine.Collider2D)o;
            UnityEngine.Rigidbody2D ret = obj.attachedRigidbody;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index attachedRigidbody on a nil value" : e.Message));
        }
    }
    static int get_rigidbody2D(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Component   obj = (UnityEngine.Component)o;
            UnityEngine.Rigidbody2D ret = obj.rigidbody2D;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index rigidbody2D on a nil value" : e.Message));
        }
    }
Esempio n. 46
0
        public void Set(UnityEngine.Rigidbody2D source, bool kinematicForParticles)
        {
            bool kinematic = !Application.isPlaying || source.isKinematic || kinematicForParticles;

            rotation       = Quaternion.AngleAxis(source.rotation, Vector3.forward);
            linearVelocity = source.velocity;

            // For some weird reason, in 2D angular velocity is measured in *degrees* per second,
            // instead of radians. Seriously Unity, WTF??
            angularVelocity = new Vector4(0, 0, source.angularVelocity * Mathf.Deg2Rad, 0);

            // center of mass in unity is affected by local rotation and poistion, but not scale. We need it expressed in world space:
            centerOfMass = source.transform.position + source.transform.rotation * source.centerOfMass;

            inertiaTensor = kinematic ? Vector3.zero : new Vector3(0, 0, (source.constraints & RigidbodyConstraints2D.FreezeRotation) != 0?0:1 / source.inertia);
            inverseMass   = kinematic ? 0 : 1 / source.mass;
        }
Esempio n. 47
0
    static int get_rigidbody2D(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.GameObject  obj = (UnityEngine.GameObject)o;
            UnityEngine.Rigidbody2D ret = obj.rigidbody2D;
            ToLua.PushSealed(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index rigidbody2D on a nil value"));
        }
    }
Esempio n. 48
0
 void FixedUpdate()
 {
     if (manager.gameState == GameManager.GAMESTATE.kIngame)
     {
         // plane sine effect- by getting the angle using arctangent
         UnityEngine.Rigidbody2D rb = getRigidBody2d();
         Vector2 direction          = rb.velocity;
         direction += offsetVelocity;
         float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
         rb.MoveRotation(angle);
         // Debug.Log ("direction: " + direction + " angle: " + angle + " velocity: " + rb.velocity);
         if (Mathf.Abs(rb.velocity.y) >= maxSpeedY)
         {
             rb.velocity = new Vector2(rb.velocity.x, Mathf.Sign(rb.velocity.y) * maxSpeedY);
         }
     }
 }
 static public int IsTouching(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 3)
         {
             UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l);
             UnityEngine.Collider2D  a1;
             checkType(l, 2, out a1);
             UnityEngine.ContactFilter2D a2;
             checkValueType(l, 3, out a2);
             var ret = self.IsTouching(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.Collider2D)))
         {
             UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l);
             UnityEngine.Collider2D  a1;
             checkType(l, 2, out a1);
             var ret = self.IsTouching(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.ContactFilter2D)))
         {
             UnityEngine.Rigidbody2D     self = (UnityEngine.Rigidbody2D)checkSelf(l);
             UnityEngine.ContactFilter2D a1;
             checkValueType(l, 2, out a1);
             var ret = self.IsTouching(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 50
0
        public override void MovePlayer(UnityEngine.Rigidbody2D m_Rigidbody)
        {
            Vector3 cur_pos = m_Rigidbody.transform.position;
            float   x       = cur_pos.x;
            float   y       = cur_pos.y;

            cur_pos.Set(x, y - 0.1f, 0);
            if (Input.GetKeyDown(upKey) && flag)
            {
                cur_pos.Set(x, y + speed, 0);
                flag = false;
            }
            if (Input.GetKeyUp(upKey))
            {
                flag = true;
            }

            m_Rigidbody.position = cur_pos;
        }
        public void FromRigidbody(UnityEngine.Rigidbody2D rb, bool kinematicForParticles)
        {
            bool kinematic = !Application.isPlaying || rb.isKinematic || kinematicForParticles;

            velocity = rb.velocity;

            // For some weird reason, in 2D angular velocity is measured in *degrees* per second,
            // instead of radians. Seriously Unity, WTF??
            angularVelocity = new Vector4(0, 0, rb.angularVelocity * Mathf.Deg2Rad, 0);

            // center of mass in unity is affected by local rotation and poistion, but not scale. We need it expressed in world space:
            com = rb.transform.position + rb.transform.rotation * rb.centerOfMass;

            Vector3 inertiaTensor = kinematic ? Vector3.zero : new Vector3(0, 0, (rb.constraints & RigidbodyConstraints2D.FreezeRotation) != 0 ? 0 : 1 / rb.inertia);

            Matrix4x4 rotation = Matrix4x4.Rotate(Quaternion.AngleAxis(rb.rotation, Vector3.forward));

            inverseInertiaTensor = rotation * Matrix4x4.Scale(inertiaTensor) * rotation.transpose;

            inverseMass = kinematic ? 0 : 1 / rb.mass;
        }
 static public int Cast(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 3)
         {
             UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l);
             UnityEngine.Vector2     a1;
             checkType(l, 2, out a1);
             UnityEngine.RaycastHit2D[] a2;
             checkArray(l, 3, out a2);
             var ret = self.Cast(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 4)
         {
             UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l);
             UnityEngine.Vector2     a1;
             checkType(l, 2, out a1);
             UnityEngine.RaycastHit2D[] a2;
             checkArray(l, 3, out a2);
             System.Single a3;
             checkType(l, 4, out a3);
             var ret = self.Cast(a1, a2, a3);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function Cast to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int AddForceAtPosition(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 3)
         {
             UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l);
             UnityEngine.Vector2     a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector2 a2;
             checkType(l, 3, out a2);
             self.AddForceAtPosition(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 4)
         {
             UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l);
             UnityEngine.Vector2     a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector2 a2;
             checkType(l, 3, out a2);
             UnityEngine.ForceMode2D a3;
             checkEnum(l, 4, out a3);
             self.AddForceAtPosition(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function AddForceAtPosition to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 54
0
 public override void OnEnable() => Component = gameObject.GetComponent <UnityEngine.Rigidbody2D>();
	void Start()
	{
		rgBody2D = GetComponent<UnityEngine.Rigidbody2D>();
		animator = GetComponent<Animator>();
	}
Esempio n. 56
0
 public override void OnStart()
 {
     targetRigidbody2D = GetDefaultGameObject(targetGameObject.Value).GetComponent <UnityEngine.Rigidbody2D>();
 }
 static public int get_collisionDetectionMode(IntPtr l)
 {
     UnityEngine.Rigidbody2D o = (UnityEngine.Rigidbody2D)checkSelf(l);
     pushValue(l, o.collisionDetectionMode);
     return(1);
 }
Esempio n. 58
0
 /// <summary>
 /// Read the data using the reader.
 /// </summary>
 /// <param name="reader">Reader.</param>
 public override object Read(ISaveGameReader reader)
 {
     UnityEngine.Rigidbody2D rigidbody2D = SaveGameType.CreateComponent <UnityEngine.Rigidbody2D> ();
     ReadInto(rigidbody2D, reader);
     return(rigidbody2D);
 }
Esempio n. 59
0
        /// <summary>
        /// Read the data into the specified value.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="reader">Reader.</param>
        public override void ReadInto(object value, ISaveGameReader reader)
        {
            UnityEngine.Rigidbody2D rigidbody2D = (UnityEngine.Rigidbody2D)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "position":
                    rigidbody2D.position = reader.ReadProperty <UnityEngine.Vector2> ();
                    break;

                case "rotation":
                    rigidbody2D.rotation = reader.ReadProperty <System.Single> ();
                    break;

                case "velocity":
                    rigidbody2D.velocity = reader.ReadProperty <UnityEngine.Vector2> ();
                    break;

                case "angularVelocity":
                    rigidbody2D.angularVelocity = reader.ReadProperty <System.Single> ();
                    break;

                case "useAutoMass":
                    rigidbody2D.useAutoMass = reader.ReadProperty <System.Boolean> ();
                    break;

                case "mass":
                    rigidbody2D.mass = reader.ReadProperty <System.Single> ();
                    break;

                case "sharedMaterial":
                    if (rigidbody2D.sharedMaterial == null)
                    {
                        rigidbody2D.sharedMaterial = reader.ReadProperty <UnityEngine.PhysicsMaterial2D> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.PhysicsMaterial2D> (rigidbody2D.sharedMaterial);
                    }
                    break;

                case "centerOfMass":
                    rigidbody2D.centerOfMass = reader.ReadProperty <UnityEngine.Vector2> ();
                    break;

                case "inertia":
                    rigidbody2D.inertia = reader.ReadProperty <System.Single> ();
                    break;

                case "drag":
                    rigidbody2D.drag = reader.ReadProperty <System.Single> ();
                    break;

                case "angularDrag":
                    rigidbody2D.angularDrag = reader.ReadProperty <System.Single> ();
                    break;

                case "gravityScale":
                    rigidbody2D.gravityScale = reader.ReadProperty <System.Single> ();
                    break;

                case "bodyType":
                    rigidbody2D.bodyType = reader.ReadProperty <UnityEngine.RigidbodyType2D> ();
                    break;

                case "useFullKinematicContacts":
                    rigidbody2D.useFullKinematicContacts = reader.ReadProperty <System.Boolean> ();
                    break;

                case "isKinematic":
                    rigidbody2D.isKinematic = reader.ReadProperty <System.Boolean> ();
                    break;

                case "freezeRotation":
                    rigidbody2D.freezeRotation = reader.ReadProperty <System.Boolean> ();
                    break;

                case "constraints":
                    rigidbody2D.constraints = reader.ReadProperty <UnityEngine.RigidbodyConstraints2D> ();
                    break;

                case "simulated":
                    rigidbody2D.simulated = reader.ReadProperty <System.Boolean> ();
                    break;

                case "interpolation":
                    rigidbody2D.interpolation = reader.ReadProperty <UnityEngine.RigidbodyInterpolation2D> ();
                    break;

                case "sleepMode":
                    rigidbody2D.sleepMode = reader.ReadProperty <UnityEngine.RigidbodySleepMode2D> ();
                    break;

                case "collisionDetectionMode":
                    rigidbody2D.collisionDetectionMode = reader.ReadProperty <UnityEngine.CollisionDetectionMode2D> ();
                    break;

                case "tag":
                    rigidbody2D.tag = reader.ReadProperty <System.String> ();
                    break;

                case "name":
                    rigidbody2D.name = reader.ReadProperty <System.String> ();
                    break;

                case "hideFlags":
                    rigidbody2D.hideFlags = reader.ReadProperty <UnityEngine.HideFlags> ();
                    break;
                }
            }
        }
Esempio n. 60
0
 public void throttleUp()
 {
     UnityEngine.Rigidbody2D rb = getRigidBody2d();
     rb.AddForce(Vector2.up * upwardForceToApply);
 }