示例#1
0
    private IEnumerator pullObject(Rigidbody collidedRigidbody)
    {
        while(Vector3.Distance(transform.parent.position, collidedRigidbody.transform.position) > 1.5f)
        {
            pullTimer -= Time.deltaTime;

            if(pullTimer < 0)
            {
                yield return new WaitForSeconds(0.333f);
                pullTimer = resetPullTimer;
            }
            else
            {
                collidedRigidbody.MovePosition(collidedRigidbody.transform.position + Vector3.up * pullSpeed * Time.deltaTime);
                yield return null;
            }
        }

        //reach top now make fall
        if (collidedRigidbody.gameObject.tag != "Player")
        {
            collidedRigidbody.AddForce(Vector3.right * 10, ForceMode.Impulse);
        }
        //		else
        //		{
        //			//atTop = true;
        //		}
    }
示例#2
0
	void Start () 
	{
		rb3d = GetComponent<Rigidbody> ();	

		//Set startup position
		rb3d.MovePosition(new Vector3(0.0f, playerAboveLevel, 0.0f));
	}
示例#3
0
 public static void Move(UnityEngine.Rigidbody rigidbody, Vector3 velocity)
 {
     if (velocity == Vector3.zero)
     {
         return;
     }
     rigidbody.MovePosition(rigidbody.position + velocity * Time.fixedDeltaTime);
 }
示例#4
0
    void Grab(Rigidbody rb)
    {
        rb.isKinematic = false;
        isGrapped = true;
        rb.MovePosition(hand.transform.position);
        rb.velocity = Vector3.zero;
        hj.connectedBody = rb;

        rb.GetComponent<Item>().checkIfKaverit();
    }
示例#5
0
    void Start()
    {
        Vector3 tangent = Vector3.zero;
        int kn = 0;

        rb = GetComponent<Rigidbody>();
        Vector3 p = transform.position;
        Vector3 np = path.FindNearestPointWorld(p, 5, ref kn, ref tangent, ref alpha);
        rb.MovePosition(np);
    }
 static public int MovePosition(IntPtr l)
 {
     try {
         UnityEngine.Rigidbody self = (UnityEngine.Rigidbody)checkSelf(l);
         UnityEngine.Vector3   a1;
         checkType(l, 2, out a1);
         self.MovePosition(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#7
0
        private void FixedUpdate()
        {
            if (!doUpdate)
            {
                return;
            }

            t += Time.deltaTime * 10;            // / timeToReachTarget;

            //rb.MovePosition(Vector3.Lerp(syncStartPosition, syncEndPosition, t));
            //rb.MoveRotation(Quaternion.Lerp(syncStartRotation, syncEndRotation, t));
            rb.MovePosition(syncEndPosition);
            rb.MoveRotation(syncEndRotation);
        }
示例#8
0
        private void Awake()
        {
            _transform = transform;
            _rigidbody = GetComponent<Rigidbody>();

            this.UpdateAsObservable()
                .Select(_ => new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")))
                .Subscribe(axis =>
                {
                    Vector3 currentPos = _transform.position;
                    currentPos += axis * Time.smoothDeltaTime * speed;
                    _rigidbody.MovePosition(currentPos);
                });
        }
示例#9
0
 static int MovePosition(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Rigidbody obj  = (UnityEngine.Rigidbody)ToLua.CheckObject(L, 1, typeof(UnityEngine.Rigidbody));
         UnityEngine.Vector3   arg0 = ToLua.ToVector3(L, 2);
         obj.MovePosition(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#10
0
    void Update()
    {
        Vector3 temp = transform.position;
        temp.y = 0f;
        transform.position = temp;

        screenPos = Camera.main.WorldToScreenPoint(transform.position);
        foreach (multi.MultiplayerHandler.PlayerData data in clientServer.multiplayerHandler.playerDB) {
            if (data.name == name) {
                body = gameObject.GetComponent<Rigidbody> ();
                body.MovePosition (new Vector3 ((float)data.posX, (float)data.posY, (float)data.posZ));

                //body.MoveRotation (new Quaternion (0f, (float)clientServer.multiplayerHandler.recD, 0f, 0f));

                Quaternion rot = new Quaternion ();
                rot.eulerAngles = new Vector3 (0, (float)data.angleY, 0);
                gameObject.transform.rotation = rot;
                gameObject.GetComponent<Animator> ().SetBool ("IsWalking", data.IsWalking);
                gameObject.GetComponentInChildren<GunAnimation> ().isShooting = data.IsShooting;             }
        }
    }
示例#11
0
 // Use this for initialization
 void Start()
 {
     RigidPlayer = GetComponent<Rigidbody>();
     RigidPlayer.MovePosition (Middle.transform.position);
     pos = 2;
 }
示例#12
0
文件: Warp.cs 项目: ajanzen/minibump
 //    void Receive(Transform warpee)
 //    {
 //        float yPosition = warpee.position.y;
 ////		warpee.position = new Vector3(transform.position.x, yPosition, transform.position.z);
 ////		warpee.position = new Vector3(spawn.position.x, yPosition, spawn.position.z);
 //
 //
 //
 ////		warpee.GetComponent<NavMeshAgent>().ResetPath();
 ////		warpee.position = new Vector3(spawn.position.x, yPosition, spawn.position.z);
 //        warpee.GetComponent<NavMeshAgent>().Warp(new Vector3(spawn.position.x, yPosition, spawn.position.z));
 //    }
 //
 //    void Send(Transform warpee)
 //    {
 //        destination.Receive(warpee);
 //    }
 void Receive(Rigidbody body)
 {
     float yPosition = body.position.y;
     body.position = new Vector3(transform.position.x, yPosition, transform.position.z);
     body.MovePosition(new Vector3(spawn.position.x, yPosition, spawn.position.z));
 }
示例#13
0
    void Update() {
        if(nIdentity == null) return;

        if (doubleScore == true) {
            doubleScoreTime -= Time.deltaTime;
            if (doubleScoreTime <= 0)
            {
                doubleScore = false;
                doubleScoreTime = doubleScoreTimeInit;
            }
        }

        if (fasterFire == true) {
            fasterFireTime -= Time.deltaTime;
            if (fasterFireTime <= 0)
            {
                fasterFire = false;
                fasterFireTime = fasterFireTimeInit; //Resets timer
                currentFireRate = fireRate; //Resets fire rate to classic fire rate. Only needed for local-viewing
            }
        }

        if (shielded == true) {
            shieldedTime -= Time.deltaTime;
            if (shieldedTime <= 0) {
                shielded = false;
                shield.SetActive(false);
                Destroy(shield);
                shieldedTime = fasterFireTimeInit; //Resets timer
            }
        }
        if (!nIdentity.isLocalPlayer) return;

        rb = GetComponent<Rigidbody>();
        Vector3 forward = transform.forward;
        Vector3 right = transform.right;
#if UNITY_ANDROID
        float aimH = CrossPlatformInputManager.GetAxis ("AimH");
        float aimV = CrossPlatformInputManager.GetAxis ("AimV");
        float moveV = CrossPlatformInputManager.GetAxis("MoveV");
        float moveH = CrossPlatformInputManager.GetAxis("MoveH");
#endif

#if UNITY_STANDALONE
        float aimH = (-(Input.GetKey("left") ? 1 : 0) + (Input.GetKey("right") ? 1 : 0));
        float aimV = ((Input.GetKey("up") ? 1 : 0) - (Input.GetKey("down") ? 1 : 0));
        float moveV = ((Input.GetKey("w") ? 1 : 0) - (Input.GetKey("s") ? 1 : 0));
        float moveH = (-(Input.GetKey("a") ? 1 : 0) + (Input.GetKey("d") ? 1 : 0));
#endif

        lastMoveH = moveH;
        lastMoveV = moveV;

        if (needsReflection && invertControls) {
            Vector3 refMove = reflectPoint(moveH, moveV);
            Vector3 refAim = reflectPoint(aimH, aimV);

            moveH = refMove[0];
            moveV = refMove[1];
            aimH = refAim[0];
            aimV = refAim[1];
        }

        float forwardSpeed = speed * moveV;
        float strafeSpeed = speed * moveH;

        Vector3 moveDir = forwardSpeed * forward + strafeSpeed * right;
        Vector3 turretDirection = ((forward * aimV) + (right * aimH)).normalized;
        rotateObject(turret, turretDirection);
        Vector3 worldPos = obsCamera.position + obsCamera.parent.transform.position;
        Vector3 newLocation = transform.position + moveDir * Time.deltaTime * 5;
        float distPlanetToCam = Vector3.Distance(planetCenter, worldPos);
        float distPlayerToCam = Vector3.Distance(newLocation, worldPos);
        rotateObject(model, moveDir.normalized);
        rb.MovePosition(newLocation);

    }
示例#14
0
 public override void OnFixedUpdate()
 {
     rigidbody.MovePosition(owner.GetValue(position));
     Finish();
 }