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


C# Actor.GetComponent方法代码示例

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


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

示例1: OnActorExit

        public override void OnActorExit(Actor actor)
        {
            Pawn pawn = actor.GetComponent<Pawn>();

            if(pawn != null)
            {
                pawn.RestoreGravity();
            }
        }
开发者ID:Putaitu,项目名称:unity-boilerplate,代码行数:9,代码来源:GravityVolume.cs

示例2: OnActorEnter

        public override void OnActorEnter(Actor actor)
        {
            Pawn pawn = actor.GetComponent<Pawn>();

            if(pawn != null)
            {
                pawn.SetGravity(this.gravity);
            }
        }
开发者ID:Putaitu,项目名称:unity-boilerplate,代码行数:9,代码来源:GravityVolume.cs

示例3: Invoke

        /**
         * Invokes this trigger
         */
        public override void Invoke(Actor actor)
        {
            Collider col = actor.GetComponent<Collider>();

            if(actor != null && col != null && actor.triggerCanChangeCollider)
            {
                col.enabled = this.isEnabled;
                col.isTrigger = this.isTrigger;

                actor.OnColliderChange();
            }
        }
开发者ID:Putaitu,项目名称:unity-boilerplate,代码行数:15,代码来源:ColliderTrigger.cs

示例4: Invoke

        /**
         * Invokes this trigger
         */
        public override void Invoke(Actor actor)
        {
            Rigidbody rigidbody = actor.GetComponent<Rigidbody>();

            if(actor != null && rigidbody != null && actor.triggerCanChangeRigidbody)
            {
                rigidbody.useGravity = this.useGravity;
                rigidbody.isKinematic = this.isKinematic;

                if(this.changeVelocity)
                {
                    rigidbody.velocity = this.velocity;
                }

                actor.OnRigidbodyChange();
            }
        }
开发者ID:Putaitu,项目名称:unity-boilerplate,代码行数:20,代码来源:RigidbodyTrigger.cs

示例5: OnInteract

        /**
         * Adds this item to the inventory
         */
        public override void OnInteract(Actor actor = null)
        {
            Inventory inventory = Inventory.FindInstance();

            if(actor != null)
            {
                inventory = actor.GetComponent<Inventory>();
            }

            if(inventory != null)
            {
                inventory.AddItem(this);
            }
            else
            {
                DebugTool.LogError("Inventory could not be found", this);
            }
        }
开发者ID:Putaitu,项目名称:unity-boilerplate,代码行数:21,代码来源:Item.cs

示例6: AddActor

    public void AddActor(Actor a)
    {
        if (a.tag == "Keeper")
        {
            a.Team = a.transform.position.x < 0 ? "Home" : "Away";
        } else if (a.tag == "Player")
        {
            //Shitty Team assignment, fix this
            bool homeTeam = a.GetComponent<PlayerSync>().LobbyTeam == "Home";

            if (Home == null)
                CreateTeams();

            if (homeTeam)
            {
                a.Team = "Home";
                Home.AddPlayer(a);
            } else
            {
                a.Team = "Away";
                Away.AddPlayer(a);
            }

            float x = homeTeam ? -20 : 20;
            a.transform.position = new Vector3(x, a.transform.position.y, Random.Range(-15, 15));            
        } 
        else if (a.tag == "AI")
        {
            bool homeTeam = true;

            a.Team = "Home";
            Home.AddPlayer(a);

            float x = homeTeam ? -20 : 20;
            a.transform.position = new Vector3(x, a.transform.position.y, Random.Range(-15, 15)); 
        }

        actors.Add(a);

    }
开发者ID:SayAllenthing,项目名称:Soccer-Game,代码行数:40,代码来源:GameManager.cs

示例7: Init

    ///////////////////////////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////////////////////////
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    public void Init( Actor _actor )
    {
        //
        actor = _actor;
        charCtrl = _actor.GetComponent<CharacterController>();
        layerMasks = Game.layerMng.GetLayerMask ( layerMaskName );
        moveDir = _actor.transform.forward;

        //
        moveSpeed = 0.0f;
        velocity = Vector3.zero;
        curPathIdx = 0;
        path = new Vector3[0];
    }
开发者ID:exdev,项目名称:ex-unity-old-deprecated,代码行数:20,代码来源:MovementState.cs

示例8: Main

        /// <summary>
        /// Entry point for the application
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            // Create the message pool
            MessagePool pool = new MessagePool();

            // Create the root actor
            Actor root = new Actor(pool);

            // Attach core systems
            root.AddComponent<UserInputHandler>();
            root.AddComponent<Renderer>();
            root.AddComponent<MaterialSystem>();
            root.AddComponent<SceneManager>();
            root.AddComponent<SceneLoader>();
            root.AddComponent<Sleeper>().TargetFPS = 60.0f;

            // Attach exit listener
            bool exit = false;
            Listener<ExitMessage> exitlistener = root.AddComponent<Listener<ExitMessage>>() as Listener<ExitMessage>;
            exitlistener.OnMessageReceived += (msg) => exit = true;

            // Initialise
            root.Init();

            // Send the initialise message
            InitialiseMessage initmsg = new InitialiseMessage();
            pool.SendMessage(initmsg);

            // Load the scene
            if (!root.GetComponent<SceneLoader>().LoadSceneFromFile("scene.json"))
            {
                Console.WriteLine("Failed to load scene!");
                Console.ReadKey();
                return;
            }

            // Setup the frame message
            FrameMessage framemsg = new FrameMessage();
            framemsg.FrameNumber = 0;
            framemsg.DeltaTime = 0.0f;

            // Setup the timer
            Stopwatch frametimer = new Stopwatch();

            // Loop until done
            while (!exit)
            {
                // Send frame message
                frametimer.Start();
                pool.SendMessage(framemsg);
                frametimer.Stop();
                framemsg.DeltaTime = (float)frametimer.Elapsed.TotalSeconds;
                frametimer.Reset();

                // Increase frame number
                framemsg.FrameNumber++;

                // Process windows events
                Application.DoEvents();
            }

            // Send the shutdown message
            ShutdownMessage shutdownmsg = new ShutdownMessage();
            pool.SendMessage(shutdownmsg);

            // Delete root actor and clean up
            root.Destroy(true);
        }
开发者ID:Knightshade,项目名称:Castle-Renderer-Failz-Edition,代码行数:72,代码来源:Program.cs

示例9: Slide_Start_Position

    public void Slide_Start_Position(Actor actor, Actor_Positions position)
    {
        RectTransform rect = actor.GetComponent<RectTransform>();

        if (position == Actor_Positions.LEFT)
            rect.localPosition = offscreen_left.localPosition;
        if (position == Actor_Positions.RIGHT)
            rect.localPosition = offscreen_right.localPosition;

        rect.localPosition = new Vector3(rect.localPosition.x, ActorManager.Get_Actor_Y_Position(actor), rect.localPosition.z);
    }
开发者ID:DeeCeptor,项目名称:VN,代码行数:11,代码来源:ActorManager.cs

示例10: DrawShadowMap

        private void DrawShadowMap(ICamera camera, Actor castingActor)
        {
            TransformComponent shadowCasterTransform = castingActor.GetComponent<TransformComponent>(ActorComponent.ComponentType.Transform);
            Matrix casterView = Matrix.Invert(shadowCasterTransform.Transform);

            // Find the front half of the frustum corners in world space.
            Matrix invCamFrustum = Matrix.Invert(camera.Frustum.Matrix);
            Vector3[] halfCamCorners = new Vector3[] {
                new Vector3(-1.0f, -1.0f, 0.0f),
                new Vector3(1.0f, -1.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f),
                new Vector3(-1.0f, 1.0f, 0.0f),
                new Vector3(-1.0f, -1.0f, 1.0f),
                new Vector3(1.0f, -1.0f, 1.0f),
                new Vector3(1.0f, 1.0f, 1.0f),
                new Vector3(-1.0f, 1.0f, 1.0f),
            };

            for (int c = 0; c < 8; ++c)
            {
                Vector4 transformedCorner = Vector4.Transform(halfCamCorners[c], invCamFrustum);
                transformedCorner /= transformedCorner.W;
                halfCamCorners[c].X = transformedCorner.X;
                halfCamCorners[c].Y = transformedCorner.Y;
                halfCamCorners[c].Z = transformedCorner.Z;
            }

            for (int c = 0; c < 4; ++c)
            {
                halfCamCorners[c + 4] = halfCamCorners[c] + 0.05f * (halfCamCorners[c + 4] - halfCamCorners[c]);
            }

            Vector3[] camCorners = camera.Frustum.GetCorners();

            // Transform those corners into to caster space, and form a bounding box around them, which will become our caster projection.
            Vector3 shadowMapFrustumMinHalfCorner = Vector3.Transform(halfCamCorners[0], casterView);
            Vector3 shadowMapFrustumMaxHalfCorner = shadowMapFrustumMinHalfCorner;
            Vector3 shadowMapFrustumMinCorner = Vector3.Transform(camCorners[0], casterView);
            Vector3 shadowMapFrustumMaxCorner = shadowMapFrustumMinHalfCorner;
            for (int fc = 1; fc < 8; ++fc)
            {
                Vector3 currTranslatedCorner = Vector3.Transform(halfCamCorners[fc], casterView);
                shadowMapFrustumMinHalfCorner = Vector3.Min(currTranslatedCorner, shadowMapFrustumMinHalfCorner);
                shadowMapFrustumMaxHalfCorner = Vector3.Max(currTranslatedCorner, shadowMapFrustumMaxHalfCorner);
                currTranslatedCorner = Vector3.Transform(camCorners[fc], casterView);
                shadowMapFrustumMinCorner = Vector3.Min(currTranslatedCorner, shadowMapFrustumMinCorner);
                shadowMapFrustumMaxCorner = Vector3.Max(currTranslatedCorner, shadowMapFrustumMaxCorner);
            }

            Matrix shadowMapProj = SpaceUtils.CreateOrthographicOffCenter(
                shadowMapFrustumMinHalfCorner.X,
                shadowMapFrustumMaxHalfCorner.X,
                shadowMapFrustumMinHalfCorner.Y,
                shadowMapFrustumMaxHalfCorner.Y,
                shadowMapFrustumMaxHalfCorner.Z + 1000.0f,  // Extra room to include shadow casting objects.
                shadowMapFrustumMinHalfCorner.Z);

            SceneGraph.ResetTraversal();
            SceneGraph.VisibilityFrustum = new BoundingFrustum(casterView * shadowMapProj);

            Resources.ShadowTransform = SceneGraph.VisibilityFrustum.Matrix * sShadowTextureShift;
            SceneGraph.ExternalMaterialFlags = TraversalContext.MaterialFlags.ShadowMap;

            SharedResources.Game.GraphicsDevice.SetRenderTarget(Resources.ShadowMap);
            SharedResources.Game.GraphicsDevice.Clear(Color.White);

            SceneGraph.Draw();
        }
开发者ID:Tengato,项目名称:Mechadrone1,代码行数:68,代码来源:Scene.cs

示例11: Seek

        // Get to a target ASAP.
        private Vector2 Seek(Actor owner)
        {
            BipedControllerComponent bcc = owner.GetComponent<BipedControllerComponent>(ActorComponent.ComponentType.Control);
            Vector3 relativeTarget = Target - BepuConverter.Convert(bcc.Controller.Body.Position);

            if (relativeTarget.X == 0.0f && relativeTarget.Z == 0.0f)
                return Vector2.Zero;

            // Rotate into controller space.
            Matrix controllerRotation = Matrix.CreateLookAt(Vector3.Zero, BepuConverter.Convert(bcc.Controller.HorizontalViewDirection), Vector3.Up);
            relativeTarget = Vector3.Transform(relativeTarget, controllerRotation);

            // Project the target onto the horizontal plane and normalize (via simple trig since we know Y == 0.0f).
            // Take theta = 0.0f is facing forward (-Z)
            double theta = Math.Atan2(-relativeTarget.X, -relativeTarget.Z);

            return new Vector2(-(float)(Math.Sin(theta)), (float)(Math.Cos(theta)));
        }
开发者ID:Tengato,项目名称:Mechadrone1,代码行数:19,代码来源:SteeringBlender.cs

示例12: AvoidObstacles

        // Steer away from obstacles in the way. This method returns a zero vector if no correction is required.
        // It should be high priority and the steering from other behaviors should blend into the remaining space.
        // So if this returns a length 1.0f vector, avoiding the obstacle is most urgent and there is no room for other
        // steering.
        private Vector2 AvoidObstacles(Actor owner)
        {
            BipedControllerComponent bcc = owner.GetComponent<BipedControllerComponent>(ActorComponent.ComponentType.Control);

            // Conditions where we do not want to use this steering force.
            if (GetAngleFromVertical(bcc.Controller.Body.LinearVelocity) < MathHelper.PiOver4 ||    // We're probably falling...
                !bcc.Controller.SupportFinder.HasSupport ||
                !bcc.Controller.SupportFinder.HasTraction)
                return Vector2.Zero;

            // Sphere cast ahead along facing.
            List<RayCastResult> obstacles = new List<RayCastResult>();
            SphereShape probe = new SphereShape(bcc.Controller.BodyRadius * 1.1f);
            RigidTransform probeStartPosition = new RigidTransform(bcc.Controller.Body.Position);
            // Add a small constant to the probe length because we want a minimum amount of forward probing, even if we are not moving.
            float probeLength = Math.Max(BepuVec3.Dot(bcc.Controller.Body.LinearVelocity, bcc.Controller.ViewDirection), 0.0f) + 1.0f;
            BepuVec3 probeSweep = bcc.Controller.ViewDirection * probeLength;
            ObstacleFilter filter = new ObstacleFilter(bcc.Controller.Body.CollisionInformation);
            GameResources.ActorManager.SimSpace.ConvexCast(probe, ref probeStartPosition, ref probeSweep, filter.Test, obstacles);

            RayCastDistanceComparer rcdc = new RayCastDistanceComparer();

            obstacles.Sort(rcdc);

            BEPUutilities.Vector3 cross = BEPUutilities.Vector3.Zero;
            int obstacleIndex = 0;
            do
            {
                if (obstacles.Count == obstacleIndex)
                    return Vector2.Zero;

                cross = BEPUutilities.Vector3.Cross(bcc.Controller.ViewDirection, -obstacles[obstacleIndex++].HitData.Normal);
            }
            while (cross.X > 0.7f); // if cross.X > 0.7f, the obstacle is some kind of gentle ramp; ignore it.

            // dot will typically be negative and magnitude indicates how directly ahead the obstacle is.
            float dot = BEPUutilities.Vector3.Dot(bcc.Controller.ViewDirection, -obstacles[0].HitData.Normal);
            if (dot >= 0.0f) // The obstacle won't hinder us if we touch it.
                return Vector2.Zero;

            // When cross.Y is positive, the object is generally to the right, so veer left (and vice versa).
            float directionSign = cross.Y >= 0.0f ? -1.0f : 1.0f;
            BEPUutilities.Vector2 result = BEPUutilities.Vector2.UnitX * directionSign * -dot;

            // Also scale response by how close the obstacle is.
            float distance = (obstacles[0].HitData.Location - bcc.Controller.Body.Position).Length();

            result *= MathHelper.Clamp((1.0f - distance / probeLength), 0.0f, 1.0f); // / Math.Abs(dot);

            // So far the result is in terms of 'velocity space'. Rotate it to align with the controller facing.
            float velocityTheta = (float)(Math.Atan2(-probeSweep.X, -probeSweep.Z));
            BEPUutilities.Matrix2x2 velocityWorld = SpaceUtils.Create2x2RotationMatrix(velocityTheta);
            float facingTheta = (float)(Math.Atan2(-bcc.Controller.HorizontalViewDirection.X, -bcc.Controller.HorizontalViewDirection.Z));
            BEPUutilities.Matrix2x2 facingWorldInv = SpaceUtils.Create2x2RotationMatrix(facingTheta);
            facingWorldInv.Transpose(); // We want the transpose/inverse of the facing transform because we want to transform the movement into 'facing space'.

            return BepuConverter.Convert(SpaceUtils.TransformVec2(SpaceUtils.TransformVec2(result, velocityWorld), facingWorldInv));
        }
开发者ID:Tengato,项目名称:Mechadrone1,代码行数:62,代码来源:SteeringBlender.cs

示例13: Arrive

        // Come to a smooth stop at a target.
        private Vector2 Arrive(Actor owner)
        {
            BipedControllerComponent bcc = owner.GetComponent<BipedControllerComponent>(ActorComponent.ComponentType.Control);
            Vector3 relativeTarget = Target - BepuConverter.Convert(bcc.Controller.Body.Position);

            relativeTarget.Y = 0.0f;

            if (relativeTarget.LengthSquared() < ARRIVE_TOLERANCE)
                return Vector2.Zero;

            float distToTarget = relativeTarget.Length();
            relativeTarget /= distToTarget;
            float normalizedSpeedToTarget = Vector3.Dot(BepuConverter.Convert(bcc.Controller.Body.LinearVelocity), relativeTarget) /
                bcc.RunSpeed;

            // Rotate into controller space.
            Matrix controllerRotation = Matrix.CreateLookAt(Vector3.Zero, BepuConverter.Convert(bcc.Controller.HorizontalViewDirection), Vector3.Up);
            relativeTarget = Vector3.Transform(relativeTarget, controllerRotation);

            Vector2 seekResult = new Vector2(relativeTarget.X, -relativeTarget.Z);

            const float DECELERATION_RADIUS = 24.0f; // Tweak this

            float closeness = Math.Max(0.0f, normalizedSpeedToTarget * normalizedSpeedToTarget - distToTarget / DECELERATION_RADIUS * Urgency);
            float brakes = closeness > 1.0f ? 1.0f : (float)(Math.Asin(closeness) / MathHelper.PiOver2);

            return (1.0f - brakes) * seekResult;
        }
开发者ID:Tengato,项目名称:Mechadrone1,代码行数:29,代码来源:SteeringBlender.cs

示例14: AbandonedSeek

        // This was my original attempt at seek, but it's not sure of what it needs to do. There are some interesting
        // computations in here that I might want to use later though.
        private Vector3 AbandonedSeek(Actor owner, Vector3 target, Plane surface)
        {
            BipedControllerComponent bcc = owner.GetComponent<BipedControllerComponent>(ActorComponent.ComponentType.Control);

            // The location of the feet is the most reliable way to get current position in a nav surface
            Vector3 bipedFeetPosition = BepuConverter.Convert(bcc.Controller.Body.Position) -
                BepuConverter.Convert(bcc.Controller.Down) * bcc.Controller.SupportFinder.RayLengthToBottom;

            Vector3 relativeTarget = target - bipedFeetPosition;
            // Project the target onto the surface plane.
            Vector3 surfaceProjectedRelativeTarget = relativeTarget - surface.Normal * Vector3.Dot(relativeTarget, surface.Normal);

            // Unlikely that we're spot on, but we must avoid divide by zero on Normalize.
            if (surfaceProjectedRelativeTarget.LengthSquared() == 0.0f)
                return Vector3.Zero;

            surfaceProjectedRelativeTarget.Normalize();

            // Difference between actual and ideal velocity. This will be the direction of our impulse with a few exceptions.
            Vector3 velocityDiff = surfaceProjectedRelativeTarget * bcc.RunSpeed - BepuConverter.Convert(bcc.Controller.Body.LinearVelocity);

            // Exception 1: We don't want to remove excess velocity that's in the target's direction.
            float deceleration = Vector3.Dot(velocityDiff, surfaceProjectedRelativeTarget);
            if (deceleration < 0)
                velocityDiff -= surfaceProjectedRelativeTarget * deceleration;

            // Normalize velocityDiff in terms of max speed.
            velocityDiff /= bcc.RunSpeed;

            float lengthSq = velocityDiff.LengthSquared();
            if (lengthSq < 1.0f)
            {
                // Exception 2 : Use up the extra impulse capacity to push against friction. Calculating the amount to add
                // so that the resulting length is one is a bit tricky:
                float fwdComp = Vector3.Dot(velocityDiff, surfaceProjectedRelativeTarget);
                float latComp = (velocityDiff - surfaceProjectedRelativeTarget * fwdComp).Length();

                float makeupLength = (float)(Math.Sqrt(1.0f - latComp * latComp)) - fwdComp;
                velocityDiff += makeupLength * surfaceProjectedRelativeTarget;
            }
            else if (lengthSq > 1.0f)
            {
                // Clamp
                velocityDiff.Normalize();
            }

            return velocityDiff;
        }
开发者ID:Tengato,项目名称:Mechadrone1,代码行数:50,代码来源:SteeringBlender.cs

示例15: ComputeForce

        public Vector2 ComputeForce(Actor owner)
        {
            // Aggregate the behaviors to produce an initial 'immediate' result:
            Vector2 result = Vector2.Zero;
            if (Weights[(int)WeightType.Seek] > 0.0f)
                result += Weights[(int)WeightType.Seek] / TotalWeight * Seek(owner);

            if (Weights[(int)WeightType.Arrive] > 0.0f)
                result += Weights[(int)WeightType.Arrive] / TotalWeight * Arrive(owner);

            if (Weights[(int)WeightType.Wander] > 0.0f)
                result += Weights[(int)WeightType.Wander] / TotalWeight * Wander();

            if (Weights[(int)WeightType.Wait] > 0.0f)
                result += Weights[(int)WeightType.Wait] / TotalWeight * Wait();

            result = FitIntoSlack(result, AvoidObstacles(owner));

            // Create a 3D version of the result (so we can transform it using rotation about the y-axis)
            Vector3 res3D = new Vector3(result.X, 0.0f, -result.Y);

            // Keep a history of unit force directions, in world space.  And magnitudes.
            // Rotate into world space before storing so the history is all in the same space.
            BipedControllerComponent bcc = owner.GetComponent<BipedControllerComponent>(ActorComponent.ComponentType.Control);
            Matrix controllerRotation = Matrix.Transpose(Matrix.CreateLookAt(Vector3.Zero, BepuConverter.Convert(bcc.Controller.HorizontalViewDirection), Vector3.Up));
            res3D = Vector3.Transform(res3D, controllerRotation);

            // Store in the history arrays;
            mHistoryIndex = (mHistoryIndex + 1) % HISTORY_SIZE;
            mForceHistory[mHistoryIndex] = res3D.Length();
            if (mForceHistory[mHistoryIndex] != 0.0f)
            {
                mDirHistory[mHistoryIndex] = res3D / mForceHistory[mHistoryIndex];
            }
            else
            {
                mDirHistory[mHistoryIndex] = Vector3.Forward;
            }

            // Get the average direction:
            Vector3 dirAvg = Vector3.Zero;
            for (int v = 0; v < HISTORY_SIZE; ++v)
            {
                int vIndex = (mHistoryIndex - v + HISTORY_SIZE) % HISTORY_SIZE;
                dirAvg += mDirHistory[vIndex] * (HISTORY_SIZE - v);  // Weight to favor more recent entries.
            }

            if (dirAvg.LengthSquared() != 0.0f)
                dirAvg.Normalize();

            // avgTheta is a measure of how much each direction in the history varies with the average.
            float avgTheta = 0.0f;
            int numWeights = ((HISTORY_SIZE + 1) * HISTORY_SIZE) / 2;
            for (int v = 0; v < HISTORY_SIZE; ++v)
            {
                int vIndex = (mHistoryIndex - v + HISTORY_SIZE) % HISTORY_SIZE;
                avgTheta += mForceHistory[vIndex] == 0.0f ? 0.0f : (float)(Math.Acos(MathHelper.Clamp(Vector3.Dot(mDirHistory[vIndex], dirAvg), 0.0f, 1.0f))) * (float)(HISTORY_SIZE - v);
            }

            avgTheta /= (float)numWeights;

            // If avgTheta is large, the immediate forces are jittery, and we should use more history to smooth out the final result.
            // otherwise, the immediate force is more continuous and we can use fewer histories.

            int numHistoriesToUse = Math.Max((int)(Math.Min(avgTheta / MathHelper.Pi * 8.0f, 1.0f) * (float)HISTORY_SIZE), 1);

            // In addition, we give recent forces more weight using a simple arithmetic sequence.
            numWeights = ((numHistoriesToUse + 1) * numHistoriesToUse) / 2;

            res3D = Vector3.Zero;
            for (int v = 0; v < numHistoriesToUse; ++v)
            {
                int vIndex = (mHistoryIndex - v + HISTORY_SIZE) % HISTORY_SIZE;
                res3D += mDirHistory[vIndex] * (float)(numHistoriesToUse - v) * mForceHistory[vIndex];
            }

            res3D /= (float)(numWeights);

            // Back again into controller space:
            controllerRotation = Matrix.Transpose(controllerRotation);
            res3D = Vector3.Transform(res3D, controllerRotation);

            result.X = res3D.X;
            result.Y = -res3D.Z;
            return result * ForceScale;
        }
开发者ID:Tengato,项目名称:Mechadrone1,代码行数:86,代码来源:SteeringBlender.cs


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