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

C# UnityEngine.Vector2类代码示例

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

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



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

示例1: AttachBodiesWithSliderJoint

        /// <summary>
        /// Attaches the bodies with revolute joints.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodies">The bodies.</param>
        /// <param name="localAnchorA">The local anchor A.</param>
        /// <param name="localAnchorB">The local anchor B.</param>
        /// <param name="connectFirstAndLast">if set to <c>true</c> [connect first and last].</param>
        /// <param name="collideConnected">if set to <c>true</c> [collide connected].</param>
        /// <param name="minLength">Minimum length of the slider joint.</param>
        /// <param name="maxLength">Maximum length of the slider joint.</param>
        /// <returns></returns>
        public static List<SliderJoint> AttachBodiesWithSliderJoint(World world, List<Body> bodies, Vector2 localAnchorA,
                                                                    Vector2 localAnchorB, bool connectFirstAndLast,
                                                                    bool collideConnected, float minLength,
                                                                    float maxLength)
        {
            List<SliderJoint> joints = new List<SliderJoint>(bodies.Count + 1);

            for (int i = 1; i < bodies.Count; i++)
            {
                SliderJoint joint = new SliderJoint(bodies[i], bodies[i - 1], localAnchorA, localAnchorB, minLength,
                                                    maxLength);
                joint.CollideConnected = collideConnected;
                world.AddJoint(joint);
                joints.Add(joint);
            }

            if (connectFirstAndLast)
            {
                SliderJoint lastjoint = new SliderJoint(bodies[0], bodies[bodies.Count - 1], localAnchorA, localAnchorB,
                                                        minLength, maxLength);
                lastjoint.CollideConnected = collideConnected;
                world.AddJoint(lastjoint);
                joints.Add(lastjoint);
            }

            return joints;
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:39,代码来源:PathManager.cs


示例2: FrictionJoint

 public FrictionJoint(Body bodyA, Body bodyB, Vector2 localAnchorA, Vector2 localAnchorB)
     : base(bodyA, bodyB)
 {
     JointType = JointType.Friction;
     LocalAnchorA = localAnchorA;
     LocalAnchorB = localAnchorB;
 }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:7,代码来源:FrictionJoint.cs


示例3: Divide

 public static Vector2 Divide( Vector2 value1, float divider )
 {
     float factor = 1 / divider;
     value1.x *= factor;
     value1.y *= factor;
     return value1;
 }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:7,代码来源:Vector2.cs


示例4: AbstractForceController

        /// <summary>
        /// Constructor
        /// </summary>
        public AbstractForceController()
            : base(ControllerType.AbstractForceController)
        {
            Enabled = true;

            Strength = 1.0f;
            Position = new Vector2(0, 0);
            MaximumSpeed = 100.0f;
            TimingMode = TimingModes.Switched;
            ImpulseTime = 0.0f;
            ImpulseLength = 1.0f;
            Triggered = false;
            StrengthCurve = new Curve();
            Variation = 0.0f;
            Randomize = new System.Random(1234);
            DecayMode = DecayModes.None;
            DecayCurve = new Curve();
            DecayStart = 0.0f;
            DecayEnd = 0.0f;

            StrengthCurve.Keys.Add(new CurveKey(0, 5));
            StrengthCurve.Keys.Add(new CurveKey(0.1f, 5));
            StrengthCurve.Keys.Add(new CurveKey(0.2f, -4));
            StrengthCurve.Keys.Add(new CurveKey(1f, 0));
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:28,代码来源:AbstractForceController.cs


示例5: CreateDistanceJoint

 public static DistanceJoint CreateDistanceJoint(World world, Body bodyA, Body bodyB, Vector2 anchorA,
                                                 Vector2 anchorB)
 {
     DistanceJoint distanceJoint = new DistanceJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:7,代码来源:JointFactory.cs


示例6: CatmullRom

        public static void CatmullRom( ref Vector2 value1, ref Vector2 value2, ref Vector2 value3, ref Vector2 value4,
		                              float amount, out Vector2 result )
        {
            result = new Vector2(
                MathHelper.CatmullRom( value1.x, value2.x, value3.x, value4.x, amount ),
                MathHelper.CatmullRom( value1.y, value2.y, value3.y, value4.y, amount ) );
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:7,代码来源:Vector2.cs


示例7: CreateFixedPrismaticJoint

 public static FixedPrismaticJoint CreateFixedPrismaticJoint(World world, Body body, Vector2 worldAnchor,
                                                             Vector2 axis)
 {
     FixedPrismaticJoint joint = new FixedPrismaticJoint(body, worldAnchor, axis);
     world.AddJoint(joint);
     return joint;
 }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:7,代码来源:JointFactory.cs


示例8: CreateFixedDistanceJoint

 public static FixedDistanceJoint CreateFixedDistanceJoint(World world, Body body, Vector2 localAnchor,
                                                           Vector2 worldAnchor)
 {
     FixedDistanceJoint distanceJoint = new FixedDistanceJoint(body, localAnchor, worldAnchor);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:7,代码来源:JointFactory.cs


示例9: CircleShape

 internal CircleShape()
     : base(0)
 {
     ShapeType = ShapeType.Circle;
     _radius = 0.0f;
     _position = Vector2.zero;
 }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:7,代码来源:CircleShape.cs


示例10: AttachBodiesWithRevoluteJoint

        /// <summary>
        /// Attaches the bodies with revolute joints.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodies">The bodies.</param>
        /// <param name="localAnchorA">The local anchor A.</param>
        /// <param name="localAnchorB">The local anchor B.</param>
        /// <param name="connectFirstAndLast">if set to <c>true</c> [connect first and last].</param>
        /// <param name="collideConnected">if set to <c>true</c> [collide connected].</param>
        public static List<RevoluteJoint> AttachBodiesWithRevoluteJoint(World world, List<Body> bodies,
                                                                        Vector2 localAnchorA,
                                                                        Vector2 localAnchorB, bool connectFirstAndLast,
                                                                        bool collideConnected)
        {
            List<RevoluteJoint> joints = new List<RevoluteJoint>(bodies.Count + 1);

            for (int i = 1; i < bodies.Count; i++)
            {
                RevoluteJoint joint = new RevoluteJoint(bodies[i], bodies[i - 1], localAnchorA, localAnchorB);
                joint.CollideConnected = collideConnected;
                world.AddJoint(joint);
                joints.Add(joint);
            }

            if (connectFirstAndLast)
            {
                RevoluteJoint lastjoint = new RevoluteJoint(bodies[0], bodies[bodies.Count - 1], localAnchorA,
                                                            localAnchorB);
                lastjoint.CollideConnected = collideConnected;
                world.AddJoint(lastjoint);
                joints.Add(lastjoint);
            }

            return joints;
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:35,代码来源:PathManager.cs


示例11: EdgeShape

 public EdgeShape(Vector2 start, Vector2 end)
     : base(0)
 {
     ShapeType = ShapeType.Edge;
     _radius = Settings.PolygonRadius;
     Set(start, end);
 }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:7,代码来源:EdgeShape.cs


示例12: WeldJoint

        /// <summary>
        /// You need to specify a local anchor point
        /// where they are attached and the relative body angle. The position
        /// of the anchor point is important for computing the reaction torque.
        /// You can change the anchor points relative to bodyA or bodyB by changing LocalAnchorA
        /// and/or LocalAnchorB.
        /// </summary>
        /// <param name="bodyA">The first body</param>
        /// <param name="bodyB">The second body</param>
        /// <param name="localAnchorA">The first body anchor.</param>
        /// <param name="localAnchorB">The second body anchor.</param>
        public WeldJoint(Body bodyA, Body bodyB, Vector2 localAnchorA, Vector2 localAnchorB)
            : base(bodyA, bodyB)
        {
            JointType = JointType.Weld;

            LocalAnchorA = localAnchorA;
            LocalAnchorB = localAnchorB;
            ReferenceAngle = BodyB.Rotation - BodyA.Rotation;
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:20,代码来源:WeldJoint.cs


示例13: AttachCircle

        public static Fixture AttachCircle(float radius, float density, Body body, Vector2 offset, object userData)
        {
            if (radius <= 0)
                throw new ArgumentOutOfRangeException("radius", "Radius must be more than 0 meters");

            CircleShape circleShape = new CircleShape(radius, density);
            circleShape.Position = offset;
            return body.CreateFixture(circleShape, userData);
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:9,代码来源:FixtureFactory.cs


示例14: Path

        /// <summary>
        /// Initializes a new instance of the <see cref="Path"/> class.
        /// </summary>
        /// <param name="vertices">The vertices to created the path from.</param>
        public Path(Vector2[] vertices)
        {
            ControlPoints = new List<Vector2>(vertices.Length);

            for (int i = 0; i < vertices.Length; i++)
            {
                Add(vertices[i]);
            }
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:13,代码来源:Path.cs


示例15: LineJoint

        public LineJoint(Body bA, Body bB, Vector2 anchor, Vector2 axis)
            : base(bA, bB)
        {
            JointType = JointType.Line;

            LocalAnchorA = bA.GetLocalPoint(anchor);
            LocalAnchorB = bB.GetLocalPoint(anchor);
            LocalXAxis = bA.GetLocalVector(axis);
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:9,代码来源:LineJoint.cs


示例16: CreateBreakableBody

        /// <summary>
        /// Creates a breakable body. You would want to remove collinear points before using this.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="vertices">The vertices.</param>
        /// <param name="density">The density.</param>
        /// <param name="position">The position.</param>
        /// <returns></returns>
        public static BreakableBody CreateBreakableBody(World world, Vertices vertices, float density, Vector2 position,
                                                        object userData)
        {
            List<Vertices> triangles = EarclipDecomposer.ConvexPartition(vertices);

            BreakableBody breakableBody = new BreakableBody(triangles, world, density, userData);
            breakableBody.MainBody.Position = position;
            world.AddBreakableBody(breakableBody);

            return breakableBody;
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:19,代码来源:BodyFactory.cs


示例17: BuoyancyController

 /// <summary>
 /// Initializes a new instance of the <see cref="BuoyancyController"/> class.
 /// </summary>
 /// <param name="container">Only bodies inside this AABB will be influenced by the controller</param>
 /// <param name="density">Density of the fluid</param>
 /// <param name="linearDragCoefficient">Linear drag coefficient of the fluid</param>
 /// <param name="rotationalDragCoefficient">Rotational drag coefficient of the fluid</param>
 /// <param name="gravity">The direction gravity acts. Buoyancy force will act in opposite direction of gravity.</param>
 public BuoyancyController(AABB container, float density, float linearDragCoefficient,
                           float rotationalDragCoefficient, Vector2 gravity)
     : base(ControllerType.BuoyancyController)
 {
     Container = container;
     _normal = new Vector2(0, 1);
     Density = density;
     LinearDragCoefficient = linearDragCoefficient;
     AngularDragCoefficient = rotationalDragCoefficient;
     _gravity = gravity;
 }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:19,代码来源:BuoyancyController.cs


示例18: SliderJoint

        /// <summary>
        /// Initializes a new instance of the <see cref="SliderJoint"/> class.
        /// Warning: Do not use a zero or short length.
        /// </summary>
        /// <param name="bodyA">The first body.</param>
        /// <param name="bodyB">The second body.</param>
        /// <param name="localAnchorA">The first body anchor.</param>
        /// <param name="localAnchorB">The second body anchor.</param>
        /// <param name="minLength">The minimum length between anchorpoints</param>
        /// <param name="maxlength">The maximum length between anchorpoints.</param>
        public SliderJoint(Body bodyA, Body bodyB, Vector2 localAnchorA, Vector2 localAnchorB, float minLength,
                           float maxlength)
            : base(bodyA, bodyB)
        {
            JointType = JointType.Slider;

            LocalAnchorA = localAnchorA;
            LocalAnchorB = localAnchorB;
            MaxLength = maxlength;
            MinLength = minLength;
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:21,代码来源:SliderJoint.cs


示例19: FixedLineJoint

        public FixedLineJoint(Body body, Vector2 worldAnchor, Vector2 axis)
            : base(body)
        {
            JointType = JointType.FixedLine;

            BodyB = BodyA;

            LocalAnchorA = worldAnchor;
            LocalAnchorB = BodyB.GetLocalPoint(worldAnchor);
            LocalXAxis = axis;
        }
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:11,代码来源:FixedLineJoint.cs


示例20: Vertex

            public Vertex(WaterFace face, int offset)
            {
                Position = new UnityEngine.Vector3(
                    face.GetSingle(offset + 0),
                    face.GetSingle(offset + 2),
                    face.GetSingle(offset + 1));

                CurrentSpeed = new UnityEngine.Vector2(
                    face.GetSingle(offset + 3),
                    face.GetSingle(offset + 4));

                WaveHeight = face.GetSingle(offset + 6);
            }
开发者ID:katalist5296,项目名称:SanAndreasUnity,代码行数:13,代码来源:WaterFace.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# UniversalCoords类代码示例发布时间:2022-05-24
下一篇:
C# UnityEngine类代码示例发布时间: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