/** * @brief Applies the provided force in the body. * * @param force A {@link FPVector2} representing the force to be applied. **/ public void AddForce(FPVector2 force) { AddForce(force, ForceMode.Force); }
/** * @brief Returns all {@link FPCollider2D} within a circular area. Returns null if there is none. * * @param point Center of the circle in world space. * @param radius Radius of the circle. * @param layerMask Unity's layer mask to filter objects. **/ public static FPCollider2D[] OverlapCircleAll(FPVector2 point, FP radius, int layerMask = UnityEngine.Physics.DefaultRaycastLayers) { return((FPCollider2D[])_OverlapCircle(point, radius, Physics2D.BodySpecialSensor.ActiveAll, layerMask)); }
private void ApplyStateFrame(CharacterFrame currentFrame) { if ((currentFrame.Flags & FrameFlags.AUTO_JUMP) > 0) { //we want to jump, get the jump type int jumpId = data.CanJump(); //may swap the next series of if statements to switch //check if we can jump (0 means we can't) if (jumpId > 0) { //player wants to air jump if (jumpId == 2) { //increment the number of current air jumps data.moveCondition.curAirJumps += 1; //Debug.Log("jumping"); } //gets the jump velocity and sets it to the y value. calcVelocity.y = data.moveStats.jumpForce; } } //if the state applies its own custom velocity if ((currentFrame.Flags & FrameFlags.APPLY_VEL) > 0) { int facing = 1; if (!data.moveCondition.facingRight) { facing = -1; } if ((currentFrame.Flags & FrameFlags.SET_VEL) == FrameFlags.SET_VEL) { calcVelocity = new FPVector2(facing * currentFrame.velocity.x, currentFrame.velocity.y); } else { calcVelocity += new FPVector2(facing * currentFrame.velocity.x, currentFrame.velocity.y); } } //if the state applies its own custom velocity if ((currentFrame.Flags & FrameFlags.CHANGE_DIRECTION) > 0) { //Debug.Log("trying to turn around"); //statement to change facing if (data.moveCondition.facingRight) { //face left sprite.transform.eulerAngles = new Vector3(0f, 0f, 0f); //sprite.flipX=true; data.moveCondition.facingRight = false; } else { //face right sprite.transform.eulerAngles = new Vector3(0f, 180f, 0f); //sprite.flipX=false; data.moveCondition.facingRight = true; } } //check if there are hitboxes if (currentFrame.HasHitboxes()) { //sets the data of the bitboxes //get the array for easier access HitBoxData[] hitBoxData = currentFrame.hitboxes; //get the length of for the for loop int len = hitBoxData.Length; for (int i = 0; i < len; i++) { this.hitboxObj[i].SetBoxData(hitBoxData[i], data.moveCondition.facingRight); } } }
public static FPRaycastHit2D[] RaycastAll(FPVector2 origin, FPVector2 direction, FP distance) { return(Physics2DWorldManager.instance.RaycastAll(origin, direction, distance)); }
private static object _OverlapCircle(FPVector2 point, FP radius, Physics2D.BodySpecialSensor sensorType, int layerMask = UnityEngine.Physics.DefaultRaycastLayers) { return(OverlapGeneric(new Physics2D.CircleShape(radius, 1), point, sensorType, layerMask)); }
/** * @brief Cast a circle and returns an array {@link FPRaycastHit2D} with information about all {@link FPCollider2D} found. Returns null if there is none. * * @param origin Origin of the circle in world space. * @param radius Radius of the circle. * @param direction Direction {@link FPVector2} of the cast. * @param distance Max distance to reach. * @param layerMask Unity's layer mask to filter objects. **/ public static FPRaycastHit2D[] CircleCastAll(FPVector2 origin, FP radius, FPVector2 direction, FP distance, int layerMask = UnityEngine.Physics.DefaultRaycastLayers) { return((FPRaycastHit2D[])_CircleCast(origin, radius, direction, distance, Physics2D.BodySpecialSensor.ActiveAll, layerMask)); }
/** * @brief Returns all {@link FPCollider2D} within a capsule area. Returns null if there is none. * * @param point Center of the capsule in world space. * @param size Size of the capsule. * @param direction If it is a vertical or horizontal capsule. * @param angle Rotation angle in degrees of the capsule. * @param layerMask Unity's layer mask to filter objects. **/ public static FPCollider2D[] OverlapCapsuleAll(FPVector2 point, FPVector2 size, FPCapsuleDirection2D direction, FP angle, int layerMask = UnityEngine.Physics.DefaultRaycastLayers) { return((FPCollider2D[])_OverlapCapsule(point, size, direction, angle, Physics2D.BodySpecialSensor.ActiveAll, layerMask)); }
/** * @brief Returns the first {@link FPCollider2D} within a box area. Returns null if there is none. * * @param point Center of the box in world space. * @param size Size of the box. * @param angle Rotation angle in degrees of the box. * @param layerMask Unity's layer mask to filter objects. **/ public static FPCollider2D OverlapBox(FPVector2 point, FPVector2 size, FP angle, int layerMask = UnityEngine.Physics.DefaultRaycastLayers) { return((FPCollider2D)_OverlapBox(point, size, angle, Physics2D.BodySpecialSensor.ActiveOnce, layerMask)); }
/** * @brief Returns the first {@link FPCollider2D} within a small circular area. Returns null if there is none. * * @param point Center of the point in world space. * @param layerMask Unity's layer mask to filter objects. **/ public static FPCollider2D OverlapPoint(FPVector2 point, int layerMask = UnityEngine.Physics.DefaultRaycastLayers) { return((FPCollider2D)_OverlapCircle(point, POINT_RADIUS, Physics2D.BodySpecialSensor.ActiveOnce, layerMask)); }
/** * @brief Returns all {@link FPCollider2D} within a rectangular area. Returns null if there is none. * * @param pointA Top-left corner of the rectangle. * @param radius Bottom-right corner of the rectangle. * @param layerMask Unity's layer mask to filter objects. **/ public static FPCollider2D[] OverlapAreaAll(FPVector2 pointA, FPVector2 pointB, int layerMask = UnityEngine.Physics.DefaultRaycastLayers) { return((FPCollider2D[])_OverlapArea(pointA, pointB, Physics2D.BodySpecialSensor.ActiveAll, layerMask)); }