예제 #1
0
//		public QRigiBody CreateRoundedRect(QBehavior script, float w = 10, float h = 10, float density = 1, QBodyTypes bodyType = QBodyTypes.Dynamic)
//		{
//			var d = 4f;
//			var body = new QRigiBody(script, BodyFactory.CreateRoundedRectangle(world, w.ToSim(), h.ToSim(), w.ToSim() / d, h.ToSim() / d, 10, density, script.Transform.Position.ToSim(), script.Transform.Rotation, (BodyType)bodyType, script));
//			script.Transform.Body = body;
//			Bodies.Add(body);
//			return body;
//		}

        /// <summary>
        /// Creates a Circle, turns this script into a physics object,
        /// you then need to do all updates in fixedUpdate
        /// </summary>
        /// <param name="script"></param>
        /// <param name="radius"></param>
        /// <param name="density"></param>
        /// <param name="bodyType"></param>
        /// <returns></returns>
        public QBody CreateCircle(QBehavior script, float radius = 10, float density = 1,
                                  QBodyTypes bodyType            = QBodyTypes.Dynamic)
        {
            //if the body already exists we just return that one
            QBody body = FindBody(script);

            if (body != null)
            {
                return(body);
            }
            body = new QBody(
                script,
                BodyFactory.CreateCircle(PhysicsWorld,
                                         radius.ToSim(),
                                         density,
                                         script.Transform.Position.ToSim(),
                                         (BodyType)bodyType,
                                         script));
            return(AddBody(body));
        }
예제 #2
0
        /// <summary>
        /// Creates a rectangle, turns this script into a physics object,
        /// you then need to do all updates in fixedUpdate
        /// </summary>
        /// <param name="script"></param>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <param name="density"></param>
        /// <param name="bodyType"></param>
        /// <returns></returns>
        public QBody CreateRectangle(QBehavior script, float w = 10, float h = 10, float density = 1,
                                     QBodyTypes bodyType       = QBodyTypes.Dynamic)
        {
            QBody body = FindBody(script);

            if (body != null)
            {
                return(body);
            }
            body = new QBody(script,
                             BodyFactory.CreateRectangle(PhysicsWorld,
                                                         w.ToSim(),
                                                         h.ToSim(),
                                                         density,
                                                         script.Transform.Position.ToSim(),
                                                         script.Transform.Rotation,
                                                         (BodyType)bodyType,
                                                         script));
            return(AddBody(body));
        }