• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Vector3类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Rotate

 void Rotate(float degreesAroundRight, float degreesAroundUp)
 {
     Quaternion rotation = Quaternion.Euler(-degreesAroundRight, degreesAroundUp, 0f);
     transform.rotation = rotation;
     Vector3 percheASelfie = new Vector3(0f, 0f, -_distance); // TODO: Move new outside of update
     transform.position = rotation * percheASelfie;
 }
开发者ID:Matjioe,项目名称:Training-Lyon1,代码行数:7,代码来源:OrbitCamera.cs


示例2: Plane

 public Plane(Vector3 n, float d)
     : base((int)PrimitiveType.Plane)
 {
     JiggleMath.NormalizeSafe(ref n);
     this.normal = n;
     this.d = d;
 }
开发者ID:bradleat,项目名称:trafps,代码行数:7,代码来源:Plane.cs


示例3: Update

    void Update()
    {
        // Get input vector from kayboard or analog stick and make it length 1 at most
        Vector3 inputVector = new Vector3(0/*Input.GetAxis("Horizontal")*/, Input.GetAxis("Vertical"), 0);
        if(1 < inputVector.magnitude) {
            inputVector = inputVector.normalized;
        }
        inputVector = inputVector.normalized * Mathf.Pow(inputVector.magnitude, 2);

        // Rotate input vector into camera space so up is camera's up and right is camera's right
        inputVector = Camera.main.transform.rotation * inputVector;

        // Rotate input vector to be perpendicular to character's up vector
        Quaternion camToCharacterSpace = Quaternion.FromToRotation(Camera.main.transform.forward*-1, transform.up);
        inputVector = (camToCharacterSpace * inputVector);

        // Make input vector relative to Character's own orientation
        inputVector = Quaternion.Inverse(transform.rotation) * inputVector;

        if(walkMultiplier!=1) {
            if( (Input.GetKey("left shift") || Input.GetKey("right shift")) != defaultIsWalk ) {
                inputVector *= walkMultiplier;
            }
        }

        //motor.desiredTurn = inputVector.x;
        //inputVector.x = 0;

        // Apply direction
        motor.desiredMovementDirection = inputVector;

        return;
    }
开发者ID:newton64,项目名称:Dodecahedroads,代码行数:33,代码来源:DodecaInputController.cs


示例4: SetObstacles

        private void SetObstacles()
        {
            string modelName = "tree stomp sculpture";
            float modelScale = 0.02f;
            Vector3 initRot = new Vector3(-MathHelper.PiOver2, 0, 0);
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(29, 0, -8) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(63, 0, -18) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(101, 0, -13) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(101, 0, -19) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(111, 0, -20) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(94, 0, -31) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(15, 0, -36) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(111, 0, -43) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(50, 0, -50) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(106, 0, -53) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(57, 0, -55) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(98, 0, -62) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(75, 0, -68) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(28, 0, -69) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(42, 0, -69) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(81, 0, -78) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(13, 0, -85) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(103, 0, -89) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(73, 0, -90) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(49, 0, -92) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(37, 0, -101) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(106, 0, -53) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(120, 0, -121) * Ground.TerrainScale, modelScale, initRot));
            Obstacles.Add(new BaseObject(RaceGame, modelName, Ground.Origin + new Vector3(24, 0, -122) * Ground.TerrainScale, modelScale, initRot));

            for (int i = 0; i < Obstacles.Count; ++i)
            {
                RaceGame.Components.Add(Obstacles[i]);
            }
        }
开发者ID:abusque,项目名称:racexna,代码行数:35,代码来源:Track.cs


示例5: SelfDestructor

	public void SelfDestructor(int combo, bool b){
		Combo.setCombo(combo);
		rotate = true;
		timer = 0f;
		randomRot = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 0f), Random.Range(-1f, 1f));
		Destroy(gameObject, 20f);
	}
开发者ID:jetchopper,项目名称:Rich,代码行数:7,代码来源:CubeMove.cs


示例6: Update

    void Update()
    {
        if (!_First && _Velocity != 0)
        {
            float smooth = (_Velocity > 0) ? SmoothRate : -SmoothRate;
            _Velocity -= smooth * Time.deltaTime;
            if (Mathf.Abs(_Velocity) < 0.01f) _Velocity = 0f;

            Vector3 move = new Vector3(_Velocity * -1, 0, 0);
            _Transform.Translate(move, Space.World);
        }

        if (Input.GetMouseButton(0))
        {
            if (!_First)
            {
                DragEnter();
                _First = true;
            }
            else
                DragUpdate();
        }
        else if (Input.GetMouseButtonUp(0))
        {
            _First = false;
        }
    }
开发者ID:hitnoodle,项目名称:Shader-Practice,代码行数:27,代码来源:CameraDrag.cs


示例7: Update

    // Update is called once per frame
    void Update()
    {
        //		transform.LookAt(transform.position + Camera.main.transform.rotation * Vector3.back,
        //            Camera.main.transform.rotation * Vector3.up);

        //glowAmmount -= RATE * Time.deltaTime;
        glowAmount = Mathf.Lerp(glowAmount, 0, RATE * Time.deltaTime);

        if(glowAmount < 0)
            glowAmount = 0;

        //Debug.Log(glowAmmount * AMMOUNT);

        //		Color c = Color.blue;
        //		c.a = Mathf.Clamp01(glowAmmount * AMMOUNT);
        //
        //		renderer.material.color = c;

        //glowAmmount = 1.0f;

        transform.LookAt(transform.position + previousVelocity);
        GetComponent<ParticleSystem>().startSpeed = transform.parent.rigidbody.velocity.magnitude;
        GetComponent<ParticleSystem>().emissionRate = glowAmount * AMOUNT - THRESHOLD;

        //particleEmitter.Emit(Vector3.zero, previousVelosity, 1, 1, Color.white);
        //particleEmitter.Emit(50);

        previousVelocity = transform.parent.rigidbody.velocity;
    }
开发者ID:mokacao,项目名称:StellarSwingClassic,代码行数:30,代码来源:SlowGlow.cs


示例8: Fire

 public override void Fire(Vector3 direction, Quaternion rotation)
 {
     currentDistance = 0;
         base.Fire(direction,rotation);
                 BulletProjectileUp();
       amIFired = true;
 }
开发者ID:genelikespie,项目名称:AR_Game_Winter2016,代码行数:7,代码来源:BulletProjectile.cs


示例9: Update

 // Update is called once per frame
 void Update()
 {
     offset = Vector3.Lerp(offset,Vector3.zero, 20f * Time.deltaTime);
     transform.position = Vector3.Lerp(transform.position, player.transform.position, 1.0f * Time.deltaTime);
         transform.position = new Vector3(transform.position.x,transform.position.y,-20f)+offset;
         GetComponent<Camera>().orthographicSize = Screen.height / 128f;
 }
开发者ID:zunkman,项目名称:WhyNotZoidberg,代码行数:8,代码来源:PlayerFollow.cs


示例10: MarchingCubesGo

    void MarchingCubesGo()
    {
        MarchingCubes.SetTarget (marchingCubesThreshold);
        MarchingCubes.SetWindingOrder(2, 1, 0);
        MarchingCubes.SetModeToTetrahedrons();
        MarchingCubes.SetScalar (voxelResolution);

        Vector3 minExtantPos = Vector3.one * voxelCountPerChunk * chunkStride * -0.5f * voxelResolution;

        for (int i = 0; i < chunkStride; i++) {
            for (int j = 0; j < chunkStride; j++) {
                for (int k = 0; k < chunkStride; k++) {
                    Vector3 start = new Vector3(i, j, k);
                    Vector3 end = start + Vector3.one;
                    start *= voxelCountPerChunk;
                    if (i > 0) start.x -= 1;
                    if (j > 0) start.y -= 1;
                    if (k > 0) start.z -= 1;
                    end *= voxelCountPerChunk;
                    end -= Vector3.one;
                    Mesh msh = MarchingCubes.CreateMesh (voxels, start, end);
                    msh.uv = new Vector2[msh.vertices.Length];
                    msh.RecalculateNormals();
                    msh.RecalculateBounds();
                    GameObject go = (GameObject)Instantiate (meshPrefab);
                    go.transform.position = minExtantPos;
                    go.GetComponent<MeshFilter> ().mesh = msh;
                    go.GetComponent<MeshCollider>().sharedMesh = msh;
                }
            }
        }
    }
开发者ID:Cidolfas,项目名称:Cave-Machine,代码行数:32,代码来源:TESTspitGrid.cs


示例11: UpdateWithCursor

		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		internal void UpdateWithCursor(Vector3? pCursorPosition) {
			if ( pCursorPosition == null || vIsAnimating ) {
				HighlightProgress = 0;
				vSelectionStart = null;
				IsSelectionPrevented = false;
				return;
			}

			if ( vCursorDistanceFunc == null ) {
				throw new Exception("No CursorDistanceFunction has been set.");
			}

			if ( !NavItem.IsEnabled ) {
				HighlightDistance = float.MaxValue;
				HighlightProgress = 0;
				return;
			}

			float dist = vCursorDistanceFunc((Vector3)pCursorPosition);
			float prog = Mathf.InverseLerp(vSettings.HighlightDistanceMax,
				vSettings.HighlightDistanceMin, dist);

			HighlightDistance = dist;
			HighlightProgress = prog;
		}
开发者ID:Nindustrialist,项目名称:VRBreadboarding,代码行数:27,代码来源:SegmentState.cs


示例12: CreateGrappleBeam

	public bool IsHoldingGrapple = false;	// if true the player is pulled alongwith the hook shot
	public void CreateGrappleBeam() {
		if (!IsGrappling) {
			HandPosition = transform.position;	// default for now
			RaycastHit hit;
			Player MyPlayer = gameObject.GetComponent<Player> ();
			if (Physics.Raycast (transform.position, MyPlayer.ShootForwardVector, out hit, 100)) {
				HandPosition = hit.point;
				Quaternion NewRotation = new Quaternion ();
				//NewRotation.eulerAngles = (hit.point - gameObject.transform.position);
				NewRotation.eulerAngles =  MyPlayer.ShootForwardVector;
				NewRotation = Quaternion.identity;
				//Debug.LogError ("Angle of Grapple: " + NewRotation.eulerAngles.ToString());
				GameObject MyChain = (GameObject)Instantiate (GrappleBeamPrefab, HandPosition, NewRotation);
				//NewRotation = MyChain.transform.rotation;
				MyChain.transform.LookAt(hit.point);
				//Debug.LogError ("Angle of Grapple: " + MyChain.transform.rotation.eulerAngles.ToString());
				if (IsHoldingGrapple) {
					//MyChain.transform.rotation = NewRotation;
					transform.position = MyChain.transform.GetChild (7).transform.position;
					Vector3 CharacterBodyOffset = new Vector3(0,-1.5f,0);
					transform.position = transform.position+CharacterBodyOffset;
					gameObject.AddComponent<FixedJoint> ();
					gameObject.GetComponent<FixedJoint> ().connectedBody = MyChain.transform.GetChild (7).GetComponent<Rigidbody> ();
					gameObject.GetComponent<CharacterController> ().enabled = false;
					IsGrappling = true;
					gameObject.GetComponent<Rigidbody>().isKinematic = false;
				}
			}
		}
	}
开发者ID:Deus0,项目名称:Zeltex,代码行数:31,代码来源:Grapple.cs


示例13: FixedUpdate

    // Update is called once per frame
    void FixedUpdate()
    {
        if (should_shoot) {
            // did shoot before?
            if (delay_active){
                // enough time in between passed?
                if (stopwatch.ElapsedMilliseconds > delay) {
                    stopwatch.Reset();
                    delay_active = false;
                }
            }else{
                // shoot
                Transform tmp = Instantiate(bullet, transform.position, Quaternion.identity) as Transform;
                GameObject spawned_bullet = tmp.gameObject;
                spawned_bullet.layer = this.gameObject.layer;

                direction = (ship.transform.position - this.transform.position).normalized;
                /*
                // add spread
                direction = new Vector3(direction.x + Random.Range(-accuarcy_spread, accuarcy_spread),
                                        direction.y + Random.Range(-accuarcy_spread, accuarcy_spread),
                                        direction.z + Random.Range(-accuarcy_spread, accuarcy_spread));
        */
                spawned_bullet.transform.rotation = Quaternion.LookRotation(direction);
                spawned_bullet.GetComponent<Rigidbody>().AddForce(direction * bullet_speed);

                stopwatch.Start();
                delay_active = true;
            }
        }
    }
开发者ID:doctordebug,项目名称:GameDesign2015,代码行数:32,代码来源:T4TurretTrigger.cs


示例14: Start

    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < this.transform.childCount; i++) {
            GameObject obj = this.transform.GetChild(i).gameObject;
            Animator animator = obj.GetComponentInChildren<Animator>();
            this.animatorList.Add(animator);
            obj.SetActive(false);
        }

        switch (showType) {
        case ShowType.Enumeration: {
            for(int i = 0; i < animatorList.Count; i++){
                GameObject obj = animatorList[i].transform.parent.gameObject;
                obj.SetActive(true);
                float x = -20 + (i / 5) * 5;
                float y = 10 - (i % 5) * 5;
                Vector3 pos = new Vector3(x, y, i);
                obj.transform.localPosition = pos;
            }
            break;
        }
        case ShowType.Queue: {
            if(animatorList.Count >= 1){
                currentAnimator = animatorList[0];
                GameObject obj = currentAnimator.transform.parent.gameObject;
                obj.SetActive(true);
            }
            break;
        }
        }
    }
开发者ID:ootake,项目名称:SpriteStudioForUnity,代码行数:32,代码来源:SampleManager.cs


示例15: GetTarget

 public static Obj_AI_Hero GetTarget(this Spell spell,
     bool ignoreShields = true,
     Vector3 from = default(Vector3),
     IEnumerable<Obj_AI_Hero> ignoredChampions = null)
 {
     return TargetSelector.GetTarget(spell, ignoreShields, from, ignoredChampions);
 }
开发者ID:juan2202,项目名称:LeagueSharp-Standalones,代码行数:7,代码来源:Extensions.cs


示例16: Update

    public void Update()
    {
        if (Input.GetMouseButtonDown(0)
            && SpaceTraderConfig.LocalPlayer
            && SpaceTraderConfig.LocalPlayer.Ship)
        {
            var pos = new Vector3(Input.mousePosition.x, Input.mousePosition.y);
            var ray = SpaceTraderConfig.WorldMap.Camera.ScreenPointToRay(pos);

            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, float.PositiveInfinity, LayerMask.GetMask("World Map")))
            {
                //the only things on this layer with colliders should be markers
                var mapArea = hit.collider.GetComponent<WorldMapMarker>().Area;

                SpaceTraderConfig.LocalPlayer.Ship.Target = mapArea.GetComponent<Targetable>();

                Debug.Log("targetted area " + mapArea);
            }
        }

        float eastWest = Input.GetAxis("yaw");
        float northSouth = Input.GetAxis("pitch");

        const float PAN_SPEED = 50;

        camOffset += PAN_SPEED * Time.deltaTime * new Vector3(eastWest, 0, northSouth);
        var lerped = Vector3.Lerp(mapCamera.transform.position, camOffset, 2 * Time.deltaTime);

        var camXform = mapCamera.transform;
        camXform.position = lerped;
    }
开发者ID:spriest487,项目名称:spacetrader-unity,代码行数:32,代码来源:WorldMapScreen.cs


示例17: SpawnWaves

    private ScoreboardController _scoreboardController; // hold reference to ScoreboardController

    #endregion Fields

    #region Methods

    IEnumerator SpawnWaves()
    {
        yield return new WaitForSeconds(startWait);

        while (true)
        {
            for (int i = 0; i < hazardCount; i++)
            {
                Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y,
                    spawnValues.z);
                Quaternion spawnRotation = Quaternion.identity;
                // spawn with no rotation, this is already defined in RandomRotator.cs
                Instantiate(hazard, spawnPosition, spawnRotation);
                yield return new WaitForSeconds(spawnWait);
            }
            yield return new WaitForSeconds(waveWait);

            if (_scoreboardController.IsGameOver())
            {
                _scoreboardController.restartLabel.text = "Press 'R' to Restart";
                _scoreboardController.SetRestart(true);
                break;
            }
        }
    }
开发者ID:BrahmRamkissoon,项目名称:COMP305-Assignment01,代码行数:31,代码来源:GameController.cs


示例18: Add

 public Vector3 Add(ref Vector3 v)
 {
     return new Vector3(
         x: x + v.x,
         y: y + v.y,
         z: z + v.z);
 }
开发者ID:aguldstrand,项目名称:Stuff,代码行数:7,代码来源:Vector3.cs


示例19: TakeDamage

    public bool TakeDamage(int amount, Vector3 hitPoint)
    {
        // If the enemy is dead...
        if (isDead)
            // ... no need to take damage so exit the function.
            return false;

        // Play the hurt sound effect.
        //enemyAudio.Play();

        // Reduce the current health by the amount of damage sustained.
        currentHealth -= amount;
        healthPercent = Mathf.CeilToInt((currentHealth * 1.0f) / (startingHealth) * 100);
        // Set the position of the particle system to where the hit was sustained.
        //hitParticles.transform.position = hitPoint;

        // And play the particles.
        //hitParticles.Play();

        // If the current health is less than or equal to zero...
        if (currentHealth <= 0)
        {
            // ... the enemy is dead.
            Death();
            return true;
        }
        return false;
    }
开发者ID:davissamuel997,项目名称:zombie_box,代码行数:28,代码来源:EnemyHealth.cs


示例20: Update

    // Update is called once per frame
    void Update()
    {
        this.transform.position += Velocity*Time.deltaTime;

        if (transform.position.x < -384)
        {
            Velocity = new Vector3(200.0f, Velocity.y, 0);
        }

        if (transform.position.x > 384)
        {
            Velocity = new Vector3(-200.0f, Velocity.y, 0);
        }

        if (pointer.renderer.enabled == false)
        {
            if (transform.position.y > 640)
            {
                pointer.rotation = Quaternion.Euler (0, 0, 0);
                pointer.renderer.enabled = true;
                controls.p1Wins++;
                StartCoroutine("timeout");
            }
            else if (transform.position.y < -640)
            {
                pointer.rotation = Quaternion.Euler (0, 0, 180);
                pointer.renderer.enabled = true;
                controls.p2Wins++;
                StartCoroutine("timeout");
            }
        }
    }
开发者ID:Kevin-Fanning,项目名称:UnknownSeal,代码行数:33,代码来源:pongBall.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Vector3D类代码示例发布时间:2022-05-24
下一篇:
C# Vector2i类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap