当前位置: 首页>>代码示例>>C#>>正文


C# Vector3.Set方法代码示例

本文整理汇总了C#中Vector3.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Set方法的具体用法?C# Vector3.Set怎么用?C# Vector3.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector3的用法示例。


在下文中一共展示了Vector3.Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

    // Update is called once per frame
    void Update()
    {
        moveDirection = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0.0f);
        moveDirection *= speed;
        if((alus.transform.localPosition.x > maxX && Input.GetAxis("Horizontal") > 0 ) || (alus.transform.localPosition.x < minX && Input.GetAxis("Horizontal") < 0 )){
            moveDirection.Set(0,moveDirection.y,moveDirection.z);

        }
        if( (alus.transform.localPosition.y < -15 && Input.GetAxis("Vertical") < 0) ||(alus.transform.localPosition.y > 40 && Input.GetAxis("Vertical") > 0)) {
            moveDirection.Set(moveDirection.x,0,moveDirection.z);

        }
        playerController.Move(moveDirection * Time.deltaTime);
        float rotation = rotationSpeed *Input.GetAxis("Horizontal");
        if((alus.transform.rotation.y < (maxRotation/10) && Input.GetAxis("Horizontal") < 0) || (alus.transform.rotation.y > (-maxRotation/10) && Input.GetAxis("Horizontal") > 0)){
        rotation = rotationSpeed *Input.GetAxis("Horizontal");

        alus.transform.Rotate(new Vector3(0,-rotation,0));

        }
        if(Input.GetAxis("Horizontal") == 0){
            if(alus.transform.rotation.y > 0 ){
            rotation = rotationSpeed * -1;
            }else{
                rotation = rotationSpeed;

            }
            alus.transform.Rotate(new Vector3(0,rotation,0));

        }
        // alus.transform.rotation.y > -0.50
    }
开发者ID:TeamMutiny,项目名称:mutiny-shmup-v2,代码行数:33,代码来源:PlayerController.cs

示例2: Update

    // Update is called once per frame
    void Update()
    {
        moveDirection = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0.0f);
        moveDirection *= speed;
        if((alus.transform.localPosition.x > maxX && Input.GetAxis("Horizontal") > 0 ) || (alus.transform.localPosition.x < minX && Input.GetAxis("Horizontal") < 0 )){
            moveDirection.Set(0,moveDirection.y,moveDirection.z);

        }
        if( (alus.transform.localPosition.y < -15 && Input.GetAxis("Vertical") < 0) ||(alus.transform.localPosition.y > 21 && Input.GetAxis("Vertical") > 0)) {
            moveDirection.Set(moveDirection.x,0,moveDirection.z);

        }
        //gameObject.transform.position = gameObject.transform.position + moveDirection*Time.deltaTime*1.5f;
        playerController.Move(moveDirection * Time.deltaTime*1.5f);
        float rotation = rotationSpeed *Input.GetAxis("Horizontal");
        if((alus.transform.rotation.y < (maxRotation/10) && Input.GetAxis("Horizontal") < 0) || (alus.transform.rotation.y > (-maxRotation/10) && Input.GetAxis("Horizontal") > 0)){
        rotation = rotationSpeed *Input.GetAxis("Horizontal");

        alus.transform.Rotate(new Vector3(0,-rotation,0));

        }
        if(Input.GetAxis("Horizontal") == 0){
            if(alus.transform.rotation.y > 0 ){
            rotation = rotationSpeed * -1;
            }else{
                rotation = rotationSpeed;

            }
            alus.transform.Rotate(new Vector3(0,rotation,0));

        }

         	if (Input.GetButton("Fire2")){
            BroadcastMessage("ActivatePowerup");

        }

        if (Input.GetButtonDown("Menu")){

            if(!paused){
            BroadcastMessage("Shooting");
            Application.LoadLevelAdditive(0);
            Time.timeScale = 0;
            hpBar.SetActive(false);
            paused = true;
            }else{
                ResumeGame();
            }

        }

        // alus.transform.rotation.y > -0.50
    }
开发者ID:TeamMutiny,项目名称:mutiny-shmup-v3,代码行数:54,代码来源:PlayerController.cs

示例3: Shoot

    public void Shoot()
    {
        if ((Input.mousePosition.x > Screen.width / 5 || Input.mousePosition.y > Screen.height / 2.5) && (Input.mousePosition.x > 60 || Input.mousePosition.y < Screen.height - 60) && Input.mousePosition.x > Screen.width / 3)
        {
            //shooting animation on character
            //anim.CrossFade("Shooting", 0f);

            Vector3 target = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
            target = Camera.main.ScreenToWorldPoint(target);
            target.Set(target.x, target.y, gameObject.transform.position.z);

            //rifle movement
            Quaternion rotation = Quaternion.LookRotation(target - transform.position, transform.TransformDirection(Vector3.up));
            rifle.transform.rotation = new Quaternion(0, 0, rotation.z, rotation.w); ;

            //bullet spawning
            GameObject obj = bullets.FirstOrDefault(x => !x.activeInHierarchy);
            if (obj == null)
            {
                obj = (GameObject)Instantiate(bullet);
                bullets.Add(obj);
            }

            obj.SetActive(true);
            obj.transform.position = new Vector3(bulletSpawn.transform.position.x,bulletSpawn.transform.position.y,0);
            obj.transform.rotation = bulletSpawn.transform.rotation;
            obj.GetComponent<Rigidbody2D>().velocity = (target - bulletSpawn.transform.position).normalized * speed;
            shoot = false;
            Invoke("CanShootAgain", 1f);
        }
    }
开发者ID:simsonimus,项目名称:Diplomarbeit,代码行数:31,代码来源:CharacterController.cs

示例4: Start

	// Use this for initialization
	void Start () {
		RotateAxis = Vector3.zero;
		RotateAxis.Set(0, 1, -0.2f);
		RotateAxis.Normalize();
				
		rotateAroundPos = canvas.transform.position;
		RectTransform rekt; 
		rekt = canvas.GetComponent<RectTransform>();
		Vector3 v3 = rekt.lossyScale;
		rotateAroundPos.z+= v3.z * 2300;

		var q = ControlsButton.transform.rotation;
		ControlsButton.transform.RotateAround (rotateAroundPos, RotateAxis, 350);
		ControlsButton.transform.rotation = q;
			
		LanguageButton.transform.RotateAround (rotateAroundPos, RotateAxis, 340);
		LanguageButton.transform.rotation = q;
			
		CreditsButton.transform.RotateAround (rotateAroundPos, RotateAxis, 330);
		CreditsButton.transform.rotation = q;

		buttons.Add (AudioButton);
		buttons.Add (ControlsButton);
		buttons.Add (LanguageButton);
		buttons.Add (CreditsButton);

		changeAlpha ();
	}
开发者ID:sweeseng789,项目名称:Interface,代码行数:29,代码来源:SettingRotate.cs

示例5: RandomVector3

 public static Vector3 RandomVector3(float max_x,float max_y, float max_z)
 {
     System.Random rand = new System.Random();
         Vector3 newVect = new Vector3();
         newVect.Set ((float)rand.NextDouble()*max_x,(float)rand.NextDouble()*max_y,(float)rand.NextDouble()*max_z );
         return newVect;
 }
开发者ID:Natosaichek,项目名称:Evolution_machines,代码行数:7,代码来源:Utilities.cs

示例6: CreateVector3

    public static Vector3 CreateVector3(double chromosomeVal,float max_x,float max_y, float max_z)
    {
        // each chromosome is a double - 8 bytes - 64 bits.  This means it has a max value of ~ 1.84467441 × 10^19
            // We want to use as much of that as possible, in principle.  So each axis of the 3 vector will have a max of about .6*10^6
            // or 600000.  Alternatively we could bit-shift it?  If we wanted it to come out nicely we could just ignore two bytes
            // and use 2 bytes for each of the axes, but that means a max value about 65000, so we're losing an order of
            // magnitude of possible variation / detail.  Anyway, this should get cleaned up a bit somehow.

            Vector3 vect = new Vector3();
            // a double has 8 bytes, or 64 bits.  We're going to bitshift the shit out of this to produce longs(16 bits).
            // one of the nice things is that with 4 longs we could represent a generic quaternion pretty effectively.
            long maxValue = 0xff;

            long x_component = ((long)chromosomeVal >> 48) & 0x000000ff;
            long y_component = ((long)chromosomeVal >> 32) & 0x000000ff;
            long z_component = ((long)chromosomeVal >> 16) & 0x000000ff;

            chromosomeVal = (chromosomeVal % 50);
            float xval = (float)chromosomeVal * max_x;
            chromosomeVal = (chromosomeVal * 10000) % 50;
            float yval = (float)chromosomeVal * max_y;
            chromosomeVal = (chromosomeVal * 10000) % 50;
            float zval = (float)chromosomeVal * max_z;

            vect.Set(xval,yval,zval);
            return vect;
    }
开发者ID:Natosaichek,项目名称:Evolution_machines,代码行数:27,代码来源:Utilities.cs

示例7: Start

 // Use this for initialization
 void Start()
 {
     //		playerEntered = false;
     //		notClosed = true;
     //		callFurther = true;
     //		angle = 0;
     Vector3 position = new Vector3(init_radius, init_radius, 0);
     //		init_angle = 0;
     //		int hide = (int)Random.Range(0,6);
     for(int i=0; i<6; i++)
     {
         float xPos = init_radius*Mathf.Cos(Mathf.Deg2Rad*init_angle);
         float yPos = init_radius*Mathf.Sin(Mathf.Deg2Rad*init_angle);
         int index = (int)Random.Range(0,level_segments.Length);
         position.Set(xPos,yPos,0);
         GameObject child = (GameObject)Instantiate(level_segments[index],position, Quaternion.identity);
         child.transform.parent = gameObject.transform;
     //			if(i == hide)
     //			{
     //				child.SetActive(false);
     //			}
         child.transform.Rotate(0,0,(240+init_angle));
         init_angle += 60;
     }
     //start_time = Time.time;
     //makeTransparent(3,start_time,0);
 }
开发者ID:kushalkadaba,项目名称:Uroboros,代码行数:28,代码来源:CreateLevel.cs

示例8: Update

 void Update()
 {
     Camera.main.fieldOfView = Options.fov;
     if (Input.GetAxis ("RotateCameraSnap") != 0) {
         camBase.localEulerAngles = new Vector3(camBase.localEulerAngles.x,
                                                camBase.localEulerAngles.y + Input.GetAxis ("RotateCameraSnap") * 180 * Time.deltaTime,
                                                camBase.localEulerAngles.z);
     }
     if (Input.GetAxis ("ResetCameraRotation") != 0) {
         camBase.localEulerAngles = new Vector3(camBase.localEulerAngles.x,
                                                0, camBase.localEulerAngles.z);
         currentZoomLevel = defaultZoomLevel;
         UpdateEyeDepth ();
     }
     float scroll = Input.GetAxis ("Mouse ScrollWheel");
     if (scroll != 0) {
         currentZoomLevel = Mathf.Clamp (currentZoomLevel - scroll * zoomSensitivity * (currentZoomLevel / 10), minZoomLevel, maxZoomLevel);
         UpdateEyeDepth ();
     }
     Vector3 move = new Vector3 (Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
     if (move.sqrMagnitude != 0) {
         move = camBase.TransformDirection (move);
         move.Set (move.x, 0, move.z);
         move = move.normalized * moveSpeed;
         camBase.localPosition += move * Time.deltaTime * Mathf.Pow(currentZoomLevel, 1.25f) / 25;
         camBase.localPosition = new Vector3 (Mathf.Clamp (camBase.localPosition.x, -80, 80), camBase.localPosition.y,
                                              Mathf.Clamp (camBase.localPosition.z, -80, 80));
     }
 }
开发者ID:Jeasonfire,项目名称:cruelty,代码行数:29,代码来源:CameraController.cs

示例9: Start

    void Start()
    {
        if (GlobalData.difficultyLevel == 1){
            totalGoods = new GameObject[]{greenGood, blueGood};
        }
        else if(GlobalData.difficultyLevel == 2){
            totalGoods = new GameObject[]{yellowGood, blueGood, greenGood};
        }
        else {
            totalGoods = new GameObject[]{redGood, blueGood, greenGood, yellowGood};
        }

        positionWhenOneGood = new Vector3();
        positionWhenOneGood.Set (transform.position.x, transform.position.y, transform.position.z);

        positionsWhenTwoGoods = new Vector3[2];
        positionsWhenTwoGoods[0].Set(transform.position.x, transform.position.y + offsetWhenTwoGoods, transform.position.z);
        positionsWhenTwoGoods[1].Set(transform.position.x, transform.position.y - offsetWhenTwoGoods, transform.position.z);

        positionsWhenThreeGoods = new Vector3[3];
        positionsWhenThreeGoods[0].Set(transform.position.x, transform.position.y + offsetWhenThreeGoods, transform.position.z);
        positionsWhenThreeGoods[1].Set(transform.position.x, transform.position.y, transform.position.z);
        positionsWhenThreeGoods[2].Set(transform.position.x, transform.position.y - offsetWhenThreeGoods, transform.position.z);

        currentGoods = new GameObject[1];
        GenerateNewLot();

        rate = rateOfChange;
    }
开发者ID:vekkna,项目名称:Lunar-Market,代码行数:29,代码来源:LotScript.cs

示例10: Start

 // Use this for initialization
 void Start()
 {
     startTime = Time.time;
     startMarker = transform.position;
     endMarker = startMarker;
     endMarker.Set(endMarker.x, endMarker.y - distance, endMarker.z);
     journeyLength = Vector3.Distance(startMarker, endMarker);
 }
开发者ID:jmccormack200,项目名称:MeshMapper,代码行数:9,代码来源:RotateNode.cs

示例11: ApplyVector3FromLocalVector2

 public void ApplyVector3FromLocalVector2(ref Vector3 outVector, Vector2 localVector, float z)
 {
     outVector.Set
     (
         localVector.x*a + localVector.y*c + tx,
         localVector.x*b + localVector.y*d + ty,
         z
     );
 }
开发者ID:narutopatel,项目名称:Futile,代码行数:9,代码来源:FMatrix.cs

示例12: OnPlayerDeath

    void OnPlayerDeath()
    {
        GetComponent<Camera>().targetTexture = null;
        popUpDisplay.SetActive(false);

        Vector3 newPosition = new Vector3();
        newPosition.Set(target.transform.position.x, 200, target.transform.position.z);
        SetPosition(newPosition);
        SetRotation(new Vector3(90, 0, 0));
    }
开发者ID:ludu12,项目名称:SoftwareEngProject,代码行数:10,代码来源:OverHeadCameraController.cs

示例13: OnJoinedRoom

    void OnJoinedRoom()
    {
		Debug.Log (isHost);
		Vector3 location = new Vector3();
		location.Set (-0.0f, -0.0f, -1.00f);
		GameObject player = PhotonNetwork.Instantiate("New Prefab", location, Quaternion.identity, 0);
        player.GetComponent<myThirdPersonController>().isControllable = true;
		player.GetComponent<myThirdPersonController>().isHost = isHost;
		isHost = false;
    }
开发者ID:hfiller,项目名称:hackthenorth2014,代码行数:10,代码来源:RandomMatchmaker.cs

示例14: enemyWave

 void enemyWave()
 {
     waves++;
     for (int i = 0; i < noEnemies; i++) {
         int rand = Random.Range (0, 5);
         Vector3 pos = new Vector3 (13, 0, Random.Range(-7f, 9f));
         GameObject Enemey = Instantiate (enemies[rand], pos, Quaternion.identity) as GameObject;
         pos.Set (pos.x * -1f, pos.y, Random.Range (-7f, 9f));
         GameObject Enemy = Instantiate (enemies[rand], pos, Quaternion.identity) as GameObject;
     }
 }
开发者ID:zchapman,项目名称:ITCS4236,代码行数:11,代码来源:LevelTimer.cs

示例15: Follow

    private float relCameraPosMag; // The distance of the camera from the player.

    #endregion Fields

    #region Methods

    public void Follow(GameObject player)
    {
        // Setting up the reference.
        //player = GameObject.FindGameObjectWithTag("Player").transform;
        this.player = player.transform;

        // Setting the relative position as the initial relative position of the camera in the scene.
        relCameraPos = transform.position - this.player.position;
        relCameraPos.Set(0, 0, relCameraPos.z);
        relCameraPosMag = relCameraPos.magnitude - 0.5f;
    }
开发者ID:keisec,项目名称:YADC,代码行数:17,代码来源:cameraMovementScript.cs


注:本文中的Vector3.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。