Joint that keeps two Rigidbody2D objects a fixed distance apart.

Inheritance: AnchoredJoint2D
コード例 #1
0
    public override void Initialize(SkillShotBullet bullet)
    {
        base.Initialize(bullet);

        Rigidbody2D rigid = bullet.Source.GetComponentInParent<Rigidbody2D>();
        joint = rigid.gameObject.AddComponent<DistanceJoint2D>();
        joint.enabled = false;
        joint.maxDistanceOnly = true;
        //joint.connectedBody = puckRigid;
        joint.enableCollision = true;

        GameObject selfSpawnedVisuals = SimplePool.Spawn(visualsPrefab);
        selfSpawnedVisuals.transform.SetParent(rigid.transform, false);
        selfVisuals = selfSpawnedVisuals.GetComponent<MindMergeVisuals>();
        //selfVisuals.target = puckRigid;
        selfVisuals.flowIn = false;

        GameObject otherSpawnedVisuals = SimplePool.Spawn(visualsPrefab);
        otherVisuals = otherSpawnedVisuals.GetComponent<MindMergeVisuals>();
        otherVisuals.target = rigid;
        otherVisuals.flowIn = true;
        otherInterrupt = otherSpawnedVisuals.AddComponent<InterruptableProxy>();
        otherInterrupt.source = this;
        otherInterrupt.enabled = false;

        selfSpawnedVisuals.SetActive(false);
        otherSpawnedVisuals.SetActive(false);
    }
コード例 #2
0
 //Use for grabbing script and component references
 void Awake()
 {
     joint = GetComponent<DistanceJoint2D>();
     joint.enabled = false;
     lineRend = GetComponent<LineRenderer>();
     hThrow = GetComponent<HookThrow>();
 }
 public OpponentJoints(Rigidbody2D rigid, DistanceJoint2D joint, MindMergeVisuals selfVisuals, MindMergeVisuals otherVisuals)
 {
     this.rigid = rigid;
     this.joint = joint;
     this.selfVisuals = selfVisuals;
     this.otherVisuals = otherVisuals;
 }
コード例 #4
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.DistanceJoint2D o;
     o = new UnityEngine.DistanceJoint2D();
     pushObject(l, o);
     return(1);
 }
コード例 #5
0
ファイル: PlayerScript.cs プロジェクト: Dan12/hookninja
    // Update is called once per frame
    void Update()
    {
        // if mouse is pressed...
        if (Input.GetButtonDown ("Fire1") && !gameOver) {

            // this is how I fire a ray cast to check for objects under the mouse
            RaycastHit2D hit = Physics2D.Raycast (Camera.main.ScreenToWorldPoint (Input.mousePosition), Vector2.zero);

            // if there's a collision and the colliding game object has been tagged as "Wall"...
            if (hit.collider != null && hit.collider.gameObject.CompareTag("Wall")) {

                // adding a distance joint to the player
                hookJoint = gameObject.AddComponent<DistanceJoint2D>() as DistanceJoint2D;

                // connecting the distance joint to the object under the mouse
                hookJoint.connectedBody = hit.collider.GetComponent<Rigidbody2D>();

                // calculating the distance between the player and the object under the mouse
                float distance = Vector2.Distance(hit.transform.position, transform.position);

                // setting distance joint distance accordingly
                hookJoint.distance = distance;

                // objects connected by the joint can collide
                hookJoint.enableCollision = true;

                // this LineRenderer has two points, marked as "0" and "1". Setting "0" points to wall position
                rope.SetPosition(0, hit.transform.position);
            }
        }

        // if mouse is released...
        if (Input.GetButtonUp("Fire1") && !gameOver) {

            // if there is a distance joint...
            if (hookJoint) {

                // destroying the joint
                Destroy(hookJoint);

                // setting hookJoint variable to null
                hookJoint = null;

                // setting "0" and "1" points in the same position will cause the rope not to render
                rope.SetPosition(0, new Vector3(0, 0, 0));
                rope.SetPosition(1, new Vector3(0, 0, 0));
            }
        }

        // if there is a distance joint...
        if (hookJoint) {

            // shorten its distance by 0.05%
            hookJoint.distance = hookJoint.distance * hookInvSpeed;

            // setting "1" points of rope LineRenderer to player position, causing the rope to be displayed
            rope.SetPosition(1, transform.position);
        }
    }
コード例 #6
0
ファイル: MaceWeapon.cs プロジェクト: dfineberg/Pot-Smasher
 void Start()
 {
     maceObject = (GameObject)Instantiate(macePrefab, transform.position, Quaternion.identity);
     Mace mace = maceObject.GetComponentInChildren<Mace>();
     maceRigidbody = mace.GetComponent<Rigidbody2D>();
     playerJoint = mace.playerJoint;
     StartCoroutine(PlayerWait(mace));
 }
コード例 #7
0
ファイル: PlayerScript.cs プロジェクト: jstelben/Head-Hunters
	// Use this for initialization
	void Start () {
		collider  = GetComponent<BoxCollider2D>();
		body = GetComponent<Rigidbody2D>();
		joint = GetComponent<DistanceJoint2D>();
		animator = GetComponent<Animator>();
		tomahawk = joint.connectedBody;
		headCount = this.GetHeadCount();
	}
コード例 #8
0
	void Start() {
		joint = gameObject.GetComponent<DistanceJoint2D>();
		lineRenderer = gameObject.AddComponent<LineRenderer>();
		lineRenderer.material.color = c1;
		lineRenderer.SetColors(c1, c1);
		lineRenderer.SetWidth(0.02F, 0.02F);
		lineRenderer.SetVertexCount(2);
	}
コード例 #9
0
    private void Start()
    {
        joint = GetComponent<DistanceJoint2D>();
        playerC = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();

        joint.enabled = false;
        line.enabled = false;
    }
コード例 #10
0
    static public int set_distance(IntPtr l)
    {
        UnityEngine.DistanceJoint2D o = (UnityEngine.DistanceJoint2D)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.distance = v;
        return(0);
    }
コード例 #11
0
    static public int set_maxDistanceOnly(IntPtr l)
    {
        UnityEngine.DistanceJoint2D o = (UnityEngine.DistanceJoint2D)checkSelf(l);
        bool v;

        checkType(l, 2, out v);
        o.maxDistanceOnly = v;
        return(0);
    }
コード例 #12
0
ファイル: GrappleControl.cs プロジェクト: jharger/ggj14
    void Awake()
    {
        grappleJoint = GetComponent<DistanceJoint2D>();
        lineRenderer = GetComponent<LineRenderer>();
        anchor = transform.FindChild("Anchor").GetComponent<SpriteRenderer>();

        transform.parent = null;

        Disconnect();
    }
コード例 #13
0
 // Use this for initialization
 void Start()
 {
     comandoBoxColl2D = comando.GetComponent<BoxCollider2D>();
     comandoSprite = comando.GetComponent<SpriteRenderer>();
     pendulumController = pendulum.GetComponent<DistanceJoint2D>();
     maximumDistanceBetweenPendulumAndMachine = 6.48f;
     pendulumRigidBody2D = pendulum.GetComponent<Rigidbody2D>();
     pendulumAquired = false;
     tryingToAquirePendulum = false;
 }
コード例 #14
0
ファイル: GrabController.cs プロジェクト: stjahns/INTD450
    public void Open()
    {
        spriteRenderer.sprite = openSprite;

        if (grabJoint != null)
        {
            Destroy(grabJoint);
            grabJoint = null;
        }
    }
コード例 #15
0
ファイル: GrapplingEnd.cs プロジェクト: slehmann1/purgatory
 public void Setup(GameObject newStem)
 {
     dist = GetComponent<DistanceJoint2D>();
     stem = newStem;
     dist.enabled = true;
     dist.connectedBody = transform.parent.transform.parent.rigidbody2D;
     dist.enabled = false;
     transform.parent = stem.transform.parent.transform.parent;
     parts = GetComponent<ParticleSystem>();
 }
コード例 #16
0
ファイル: GrappleHook.cs プロジェクト: ironpencil/critomit
 // Use this for initialization
 public override void Start()
 {
     base.Start();
     dummySpring = GetComponent<SpringJoint2D>();
     hook = GetComponent<DistanceJoint2D>();
     if (soundEffectHandler == null)
     {
         soundEffectHandler = gameObject.GetComponent<SoundEffectHandler>();
     }
 }
コード例 #17
0
ファイル: Bead.cs プロジェクト: RBazelais/Tonal
	// Use this for initialization
	void Start () {
		isActive = true;
		//assign distance joint 2d to the component made in the editor
		dj2d = gameObject.GetComponent<DistanceJoint2D> ();
		dj2d.enabled = false;
		//assign rigidbody2d to the rigidbody of the bead
		rb2d = gameObject.GetComponent<Rigidbody2D> ();
		musicalPhrase = gameObject.GetComponent<AudioSource> ();
	
	}
コード例 #18
0
 static public int get_maxDistanceOnly(IntPtr l)
 {
     try {
         UnityEngine.DistanceJoint2D self = (UnityEngine.DistanceJoint2D)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.maxDistanceOnly);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #19
0
 static public int get_maxDistanceOnly(IntPtr l)
 {
     try {
         UnityEngine.DistanceJoint2D self = (UnityEngine.DistanceJoint2D)checkSelf(l);
         pushValue(l, self.maxDistanceOnly);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #20
0
 static public int get_autoConfigureDistance(IntPtr l)
 {
     try {
         UnityEngine.DistanceJoint2D self = (UnityEngine.DistanceJoint2D)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.autoConfigureDistance);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #21
0
ファイル: GrapplingHook.cs プロジェクト: Daankovski/Mythe
	// Use this for initialization
	void Start () {
        hookStart = GameObject.Find("chainStart");
        player = GameObject.Find("Player");
        playerBehaviour = GameObject.Find("Player").GetComponent<PlayerBehaviour>();
        joint = GameObject.Find("Player").GetComponent<DistanceJoint2D>();
        joint.enabled = false;
        line = GameObject.Find("grapplinghook").GetComponent<LineRenderer>();
        line.enabled = false;        
        maxDistance = 20f;
        
        
	}
コード例 #22
0
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.DistanceJoint2D o;
			o=new UnityEngine.DistanceJoint2D();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
コード例 #23
0
ファイル: MedusaHealth.cs プロジェクト: Rolom/medusa
 public void detachTentacle()
 {
     if(tentacleList.Count>=1){
         Transform selectedTentacle=tentacleList[Random.Range(0,tentacleList.Count)];
         sTentacle=selectedTentacle.GetComponent<DistanceJoint2D>();
         sTentacle.enabled=false;
         rTentacle=selectedTentacle.GetComponent<Rigidbody2D>();
         rTentacle.mass=1;
         rTentacle.gravityScale=2;
         tentacleList.Remove(selectedTentacle);
         gameObject.GetComponent<MedusaAnimation>().setDamageFlag(true);
     }
 }
コード例 #24
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.DistanceJoint2D o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.DistanceJoint2D();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
コード例 #25
0
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.DistanceJoint2D o;
         o=new UnityEngine.DistanceJoint2D();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
コード例 #26
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.DistanceJoint2D o;
         o = new UnityEngine.DistanceJoint2D();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #27
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.DistanceJoint2D o;
         o = new UnityEngine.DistanceJoint2D();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #28
0
ファイル: Ball.cs プロジェクト: Cestt/Prototipes
 void Start()
 {
     joint = GetComponent<DistanceJoint2D> ();
     timer = GameObject.Find ("Timer").GetComponent < TextMesh> ();
     time = 2.00f;
     timer.text = time.ToString ("F2");
     rigibody = GetComponent<Rigidbody2D> ();
     posIni = transform.position;
     rigibody.gravityScale = gravity;
     gravityIni = gravity;
     procedural = GameObject.Find ("Procedural_Manager").GetComponent<Procedural_Manager> ();
     dir = -1;
     velocity = 0;
 }
コード例 #29
0
 static public int set_maxDistanceOnly(IntPtr l)
 {
     try {
         UnityEngine.DistanceJoint2D self = (UnityEngine.DistanceJoint2D)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.maxDistanceOnly = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #30
0
ファイル: Grapple.cs プロジェクト: provencher/TalosOrigins
    // Use this for initialization
    void Start()
    {
        mTalos = GameObject.Find("Talos").GetComponent<Player>();
        grapple = GetComponent<DistanceJoint2D>();
        grapple.enabled = false;
        grapple.connectedBody = anchor.gameObject.GetComponent<Rigidbody2D>();
        grapplehooked = false;
        grappleLevel = PlayerPrefs.GetInt ("Grapple");

        if (grappleDistance == default(int))
        {
            setGrappleDistance();
        }
    }
コード例 #31
0
 static public int set_distance(IntPtr l)
 {
     try {
         UnityEngine.DistanceJoint2D self = (UnityEngine.DistanceJoint2D)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.distance = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #32
0
 static void DistanceJoint2D_maxDistanceOnly(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.DistanceJoint2D _this = (UnityEngine.DistanceJoint2D)vc.csObj;
         var result = _this.maxDistanceOnly;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean arg0 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.DistanceJoint2D _this = (UnityEngine.DistanceJoint2D)vc.csObj;
         _this.maxDistanceOnly = arg0;
     }
 }
 static public int GetReactionTorque(IntPtr l)
 {
     try {
         UnityEngine.DistanceJoint2D self = (UnityEngine.DistanceJoint2D)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         var ret = self.GetReactionTorque(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #34
0
 static public int GetReactionTorque(IntPtr l)
 {
     try{
         UnityEngine.DistanceJoint2D self = (UnityEngine.DistanceJoint2D)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         System.Single ret = self.GetReactionTorque(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #35
0
 static void DistanceJoint2D_distance(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.DistanceJoint2D _this = (UnityEngine.DistanceJoint2D)vc.csObj;
         var result = _this.distance;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.DistanceJoint2D _this = (UnityEngine.DistanceJoint2D)vc.csObj;
         _this.distance = arg0;
     }
 }
コード例 #36
0
ファイル: Bead.cs プロジェクト: RBazelais/Tonal
	// Use this for initialization
	void Start () {
		isActive = true;
		//assign distance joint 2d to the component made in the editor
		dj2d = gameObject.GetComponent<DistanceJoint2D>();

		dj2d.enabled = false;
		//assign rigidbody2d to the rigidbody of the bead
		rb2d = gameObject.GetComponent<Rigidbody2D>();
        //sr = transform.Find("CoreBead").GetComponent<SpriteRenderer>();
		//sr = gameObject.GetComponent<SpriteRenderer>();
		levelManager = GameObject.FindGameObjectWithTag ("LevelManager").GetComponent<LevelManager>();

		//musicalPhrase = gameObject.GetComponent<AudioSource> ();
		//SetupBead ();
	
	}
コード例 #37
0
ファイル: Block.cs プロジェクト: KneeDeepAudio/CauseAndEffect
    void OnMouseDown ()
        {
        if (!Hinged.instance.selected)
            return;

        Hinged.instance.Chain(gameObject);
        gameObject.AddComponent<DistanceJoint2D>().enabled = false;
        dJoint = gameObject.GetComponent<DistanceJoint2D>();
        if (dJoint != null)
            {
            dJoint.enabled = false;
            dJoint.connectedBody = /*GameObject.Find("StartingBlock")*/Hinged.instance.gameObject.GetComponent<Rigidbody2D>();
            dJointDistance = dJoint.distance;
            Debug.Log("Block is connected to: " + dJoint.connectedBody);
            }
        }
コード例 #38
0
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.DistanceJoint2D distanceJoint2D = (UnityEngine.DistanceJoint2D)value;
     writer.WriteProperty("autoConfigureDistance", distanceJoint2D.autoConfigureDistance);
     writer.WriteProperty("distance", distanceJoint2D.distance);
     writer.WriteProperty("maxDistanceOnly", distanceJoint2D.maxDistanceOnly);
     writer.WriteProperty("anchor", distanceJoint2D.anchor);
     writer.WriteProperty("connectedAnchor", distanceJoint2D.connectedAnchor);
     writer.WriteProperty("autoConfigureConnectedAnchor", distanceJoint2D.autoConfigureConnectedAnchor);
     writer.WriteProperty("connectedBody", distanceJoint2D.connectedBody);
     writer.WriteProperty("enableCollision", distanceJoint2D.enableCollision);
     writer.WriteProperty("breakForce", distanceJoint2D.breakForce);
     writer.WriteProperty("breakTorque", distanceJoint2D.breakTorque);
     writer.WriteProperty("enabled", distanceJoint2D.enabled);
     writer.WriteProperty("tag", distanceJoint2D.tag);
     writer.WriteProperty("name", distanceJoint2D.name);
     writer.WriteProperty("hideFlags", distanceJoint2D.hideFlags);
 }
コード例 #39
0
ファイル: GrabController.cs プロジェクト: stjahns/INTD450
    public void Close()
    {
        spriteRenderer.sprite = closedSprite;

        int layerMask = 0;
        grabbableLayers.ForEach(l => layerMask |= 1 << LayerMask.NameToLayer(l));

        // Check if any grabbleble colliders below
        foreach (var collider in Physics2D.OverlapCircleAll(grabCheck.position, 0.2f, layerMask))
        {
            if (collider.rigidbody2D != rigidbody2D)
            {
                grabJoint = gameObject.AddComponent<DistanceJoint2D>();
                grabJoint.connectedBody = collider.rigidbody2D;
                grabJoint.anchor = grabOrigin.position - rigidbody2D.transform.position;
                grabJoint.distance = 0.1f;
                break;
            }
        }
    }
コード例 #40
0
    // Update is called once per frame
    void Update()
    {
        if (target.name == peopleCarnage.ToString()) {

            distance = Vector2.Distance (myTransform.position, target.position);

            if (distance <= range && distance > stopDistance && hooked == false) {
                //move to the player
                myTransform.position += (target.position - myTransform.position) * moveSpeed * Time.deltaTime;
            }

            if (distance <= stopDistance && !joined) {
                hooked = true;
                joined = true;
                // joint to carnage
                dj2d = gameObject.AddComponent<DistanceJoint2D> () as DistanceJoint2D;
                dj2d.connectedBody = target.GetComponent<Rigidbody2D> ();
                dj2d.distance = 0.2f;
            }
        }
    }
コード例 #41
0
ファイル: HookBehavior.cs プロジェクト: wlots/Klaustrofobia
    // Use this for initialization
    void Start()
    {
        audioSou = GetComponent<AudioSource> ();
        player = GameObject.FindGameObjectWithTag ("Player");
        body = GetComponent<Rigidbody2D> ();

        hookSpeed += GameObject.FindGameObjectWithTag ("Player").GetComponent<PlayerStats> ().hookSpeed;

        transform.parent = player.transform;

        shootDir = Input.mousePosition;
        shootDir = Camera.main.ScreenToWorldPoint(shootDir);
        shootDir = shootDir - transform.position;
        shootDir = shootDir/Mathf.Sqrt(Mathf.Pow(shootDir.x,2)+Mathf.Pow(shootDir.y,2));

        Vector2 vec = new Vector2 (shootDir.x, shootDir.y);

        body.AddForce (vec*hookSpeed*body.mass, ForceMode2D.Impulse);
        joint = GetComponent<DistanceJoint2D> ();
        playerJoint = player.GetComponent<DistanceJoint2D> ();
    }
コード例 #42
0
    protected override void Start()
    {
        Rigidbody2D rigid = GetComponentInParent<Rigidbody2D>();
        joint = rigid.gameObject.AddComponent<DistanceJoint2D>();
        joint.enabled = false;
        joint.connectedBody = puckRigid;
        GameObject selfSpawnedVisuals = SimplePool.Spawn(visualsPrefab);
        selfSpawnedVisuals.transform.SetParent(rigid.transform, false);
        selfVisuals = selfSpawnedVisuals.GetComponent<MindMergeVisuals>();
        selfVisuals.target = puckRigid;
        selfVisuals.flowIn = false;

        GameObject otherSpawnedVisuals = SimplePool.Spawn(visualsPrefab);
        otherSpawnedVisuals.transform.SetParent(puckRigid.transform, false);
        otherVisuals = otherSpawnedVisuals.GetComponent<MindMergeVisuals>();
        otherVisuals.target = rigid;
        otherVisuals.flowIn = true;

        selfSpawnedVisuals.SetActive(false);
        otherSpawnedVisuals.SetActive(false);

        base.Start();
    }
コード例 #43
0
ファイル: launcher.cs プロジェクト: Afternight/Orbit
 private void LaunchTimed()
 {
     controller=GameObject.Find ("GameController"); //finds gamecontroller
     control=controller.GetComponent<GameController>();
     player=GameObject.Find("Rocket");
     trajectory=GameObject.Find ("Trajectory");
     control.fadeneeded = false;
     if (control.camposready){
         cable=gameObject.GetComponent<DistanceJoint2D>();
         player.transform.SetParent(null);
         Destroy(trajectory); // need to change to fade away possibly TODO
         Destroy(cable);
         //force=control.ObtainScale(); //stubbed here
         force = control.trajectory.transform.localScale.y / 10;
         power.y=force;
         Rigidbody2D x = player.gameObject.GetComponent<Rigidbody2D>();
         x.AddRelativeForce (power, ForceMode2D.Impulse);
         control.GameStatus=3;
         control.fuelloading = false;
         control.fuel = control.DataPlay.InitialFuel[Application.loadedLevel];
         //control.camhook=false;
         CancelInvoke("LaunchTimed");
     }
 }
コード例 #44
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.DistanceJoint2D distanceJoint2D = (UnityEngine.DistanceJoint2D)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "autoConfigureDistance":
                    distanceJoint2D.autoConfigureDistance = reader.ReadProperty <System.Boolean> ();
                    break;

                case "distance":
                    distanceJoint2D.distance = reader.ReadProperty <System.Single> ();
                    break;

                case "maxDistanceOnly":
                    distanceJoint2D.maxDistanceOnly = reader.ReadProperty <System.Boolean> ();
                    break;

                case "anchor":
                    distanceJoint2D.anchor = reader.ReadProperty <UnityEngine.Vector2> ();
                    break;

                case "connectedAnchor":
                    distanceJoint2D.connectedAnchor = reader.ReadProperty <UnityEngine.Vector2> ();
                    break;

                case "autoConfigureConnectedAnchor":
                    distanceJoint2D.autoConfigureConnectedAnchor = reader.ReadProperty <System.Boolean> ();
                    break;

                case "connectedBody":
                    if (distanceJoint2D.connectedBody == null)
                    {
                        distanceJoint2D.connectedBody = reader.ReadProperty <UnityEngine.Rigidbody2D> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.Rigidbody2D> (distanceJoint2D.connectedBody);
                    }
                    break;

                case "enableCollision":
                    distanceJoint2D.enableCollision = reader.ReadProperty <System.Boolean> ();
                    break;

                case "breakForce":
                    distanceJoint2D.breakForce = reader.ReadProperty <System.Single> ();
                    break;

                case "breakTorque":
                    distanceJoint2D.breakTorque = reader.ReadProperty <System.Single> ();
                    break;

                case "enabled":
                    distanceJoint2D.enabled = reader.ReadProperty <System.Boolean> ();
                    break;

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

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

                case "hideFlags":
                    distanceJoint2D.hideFlags = reader.ReadProperty <UnityEngine.HideFlags> ();
                    break;
                }
            }
        }
コード例 #45
0
 static public int get_maxDistanceOnly(IntPtr l)
 {
     UnityEngine.DistanceJoint2D o = (UnityEngine.DistanceJoint2D)checkSelf(l);
     pushValue(l, o.maxDistanceOnly);
     return(1);
 }
コード例 #46
0
 private static void DistanceJoint2D_CUSTOM_INTERNAL_GetReactionForce(DistanceJoint2D joint, float timeStep, out Vector2 value)
 {
     throw new NotImplementedException("なにこれ");
 }
コード例 #47
0
 static public int get_distance(IntPtr l)
 {
     UnityEngine.DistanceJoint2D o = (UnityEngine.DistanceJoint2D)checkSelf(l);
     pushValue(l, o.distance);
     return(1);
 }
コード例 #48
0
 private static float INTERNAL_CALL_GetReactionTorque(DistanceJoint2D self, float timeStep)
 {
     throw new NotImplementedException("なにこれ");
 }
コード例 #49
0
    // Update is called once per frame
    public void Update()
    {
        if (createRope && creatingRope == false) //Remove the first false pls
        {
            CreateGraplingHook(true);
            frameCounter = 0;
            creatingRope = true;
            createRope = false;
            //freeze = true;
        }

        if (creatingRope && frameCounter % frameSpacing == 0 && frameCounter != 0 && segmentsCreated < maxSegments)
        {
            CreateGraplingHook(false);
            segmentsCreated++;
            damper -= .02f;

            tempHinge = ropeSegments[segmentsCreated - 1 + newStartIndex].AddComponent<DistanceJoint2D>();
            tempHinge.connectedBody = ropeSegments[segmentsCreated + newStartIndex].GetComponent<Rigidbody2D>();
            tempHinge.anchor = new Vector2(1f, 0f);
            tempHinge.distance = 0.01f;
            tempHinge.enableCollision = true;
        }

        frameCounter++;

        if (segmentsCreated == maxSegments)
        {
            creatingRope = false;
            newStartIndex += 1;
            newStartIndex += segmentsCreated;
            segmentsCreated = 0;
            damper = 1;
            ropeSegmentCodes.Add(0);
            freeze = true;
            ropesCreated++;
        }

        for (int i = 0; i < segmentCounters.Count; i++)
        {
            if(segmentCounters[i] > 0)
                segmentCounters[i] -= 1;
        }

        if (freeze)
        {
            if (freezeTimer != 0)
                freezeTimer--;
            else
                FreezeRope();
        }

        if (ropeSegments.Count >= 2)
        {
            UpdateTraces();
        }

        if (!foundHead)
        {
            if (!(GameObject.Find("head" + ropeNumber) == null))
            {
                head = GameObject.Find("head" + ropeNumber);
                foundHead = true;
            }
        }

        if (hasMadeHitSound == false && foundHead && !(Physics2D.OverlapCircle(new Vector2(head.transform.position.x, head.transform.position.y), .2f, ground_layers) == null))
        {
            audioController.PlayGrapplingHitSound();
            hasMadeHitSound = true;

            head.GetComponent<Rigidbody2D>().isKinematic = true;

        }
    }
コード例 #50
0
 /// <summary>
 /// Read the data using the reader.
 /// </summary>
 /// <param name="reader">Reader.</param>
 public override object Read(ISaveGameReader reader)
 {
     UnityEngine.DistanceJoint2D distanceJoint2D = SaveGameType.CreateComponent <UnityEngine.DistanceJoint2D> ();
     ReadInto(distanceJoint2D, reader);
     return(distanceJoint2D);
 }
コード例 #51
0
 public float GetReactionTorque(float timeStep)
 {
     return(DistanceJoint2D.INTERNAL_CALL_GetReactionTorque(this, timeStep));
 }
コード例 #52
0
ファイル: GrapplingStalk.cs プロジェクト: slehmann1/purgatory
	void Start(){
		joint = GetComponent<DistanceJoint2D>();//0 is to block, 1 is to player
		joint.connectedBody=transform.parent.rigidbody2D;
	}
コード例 #53
0
 private static extern float INTERNAL_CALL_GetReactionTorque(DistanceJoint2D self, float timeStep);
コード例 #54
0
ファイル: GrappleComponent.cs プロジェクト: stjahns/INTD450
    void RetractGrapple(bool immediate = false)
    {
        if (immediate || IsArm)
        {
            state = State.Cocked;
            PlayerBehavior.Player.RefreshInputHints();

            if (sliderJoint)
            {
                Destroy(sliderJoint);
                sliderJoint = null;
            }

            if (distanceJoint)
            {
                Destroy(distanceJoint);
                distanceJoint = null;
            }

            // Retract grappling hook back to base
            projectile.ResetProjectile();
            shouldAim = true;
            fired = false;

            SFXSource.PlayOneShot(releaseClip);
            spriteRenderer.sprite = cockedSprite;
        }
        else
        {
            // if stuck in ground, slide down to retract first...
            if (projectile.AttachedToPoint)
            {
                state = State.Retracting;
                PlayerBehavior.Player.RefreshInputHints();
            }
            else
            {
                RetractGrapple(true);
            }
        }
    }
コード例 #55
0
 private static extern void DistanceJoint2D_CUSTOM_INTERNAL_GetReactionForce(DistanceJoint2D joint, float timeStep, out Vector2 value);