Post by afrien0814 on Jul 26, 2021 16:33:41 GMT
Hi, I'm now working on a spotlight feature w/ PC2D plugin.
Camera should move to specific position and zoom in when the spotlight is on, and go back to normal after turning off the spotlight.
But the camera moves unexpectedly after I use MoveCameraInstantlyToPosition() to move camera.
Please help me to check if I used the plugin wrongly.
Here's some of my code:
Thing goes well when the SpotlightOn is called.
However, when the SpotlightOff is called, some issue happend:
1. Move camera to pos → ResetMovement() assign TargetsMidPoint to camera position( = cameraSpotlightOffPos = spotlightInitCameraPos + Vector2.Right * PlayerFacing * Distance) → TargetsMidPoint goes to Player position (TargetsMidPoint - PreviousTargetsMidPoint is now opposite to PlayerFacing) → Forward Focus is enabled and make camera go to the back side of Player, but we expected camera to go to the front side of player
2. (On the down boundary) Move camera to pos → ResetMovement() assign CameraTargetPosition to camera position( = spotlightOffPos = spotlightInitCameraPos + Vector2.Right * PlayerFacing * Distance) → ForwardFocus is enabled and applies influence, so that CameraTargetPosition goes to offset (0, PlayerPos - 3) → CameraTargetPositionSmoothed first goes down then return to initial Y position
The position in the first frame = cameraSpotlightOffPos.
We expected that the camera should just horizontally move to the final position.
Please help us to do that D:
Here's some variable of my Pro Camera 2D settings:
Camera should move to specific position and zoom in when the spotlight is on, and go back to normal after turning off the spotlight.
But the camera moves unexpectedly after I use MoveCameraInstantlyToPosition() to move camera.
Please help me to check if I used the plugin wrongly.
Here's some of my code:
void SpotlightOn(Vector2 spotlightOnPos)
{
player.StopMoving();
proCamera2D.OffsetY = 0;
proCamera2D.FollowHorizontal = false;
proCamera2D.FollowVertical = false;
Vector2 spotlightInitCameraPos = proCamera2D.transform.position;
cameraSpotlightOffPos = spotlightInitCameraPos + Vector2.Right * PlayerFacing(-1 is left, and 1 is right) * Distance;
proCamera2D.MoveCameraInstantlyToPosition(spotlightOnPos);
proCamera2D.GetComponent<ProCamera2DNumericBoundaries>().enabled = false;
proCamera2D.GetComponent<ProCamera2DForwardFocus>().enabled = false;
}
void SpotlightOff()
{
proCamera2D.OffsetY = initOffsetY;
proCamera2D.FollowHorizontal = false;
proCamera2D.FollowVertical = false;
proCamera2D.MoveCameraInstantlyToPosition(cameraSpotlightOffPos);
proCamera2D.GetComponent<ProCamera2DNumericBoundaries>().enabled = false;
proCamera2D.GetComponent<ProCamera2DForwardFocus>().enabled = false;
}
{
player.StopMoving();
proCamera2D.OffsetY = 0;
proCamera2D.FollowHorizontal = false;
proCamera2D.FollowVertical = false;
Vector2 spotlightInitCameraPos = proCamera2D.transform.position;
cameraSpotlightOffPos = spotlightInitCameraPos + Vector2.Right * PlayerFacing(-1 is left, and 1 is right) * Distance;
proCamera2D.MoveCameraInstantlyToPosition(spotlightOnPos);
proCamera2D.GetComponent<ProCamera2DNumericBoundaries>().enabled = false;
proCamera2D.GetComponent<ProCamera2DForwardFocus>().enabled = false;
}
void SpotlightOff()
{
proCamera2D.OffsetY = initOffsetY;
proCamera2D.FollowHorizontal = false;
proCamera2D.FollowVertical = false;
proCamera2D.MoveCameraInstantlyToPosition(cameraSpotlightOffPos);
proCamera2D.GetComponent<ProCamera2DNumericBoundaries>().enabled = false;
proCamera2D.GetComponent<ProCamera2DForwardFocus>().enabled = false;
}
Thing goes well when the SpotlightOn is called.
However, when the SpotlightOff is called, some issue happend:
1. Move camera to pos → ResetMovement() assign TargetsMidPoint to camera position( = cameraSpotlightOffPos = spotlightInitCameraPos + Vector2.Right * PlayerFacing * Distance) → TargetsMidPoint goes to Player position (TargetsMidPoint - PreviousTargetsMidPoint is now opposite to PlayerFacing) → Forward Focus is enabled and make camera go to the back side of Player, but we expected camera to go to the front side of player
2. (On the down boundary) Move camera to pos → ResetMovement() assign CameraTargetPosition to camera position( = spotlightOffPos = spotlightInitCameraPos + Vector2.Right * PlayerFacing * Distance) → ForwardFocus is enabled and applies influence, so that CameraTargetPosition goes to offset (0, PlayerPos - 3) → CameraTargetPositionSmoothed first goes down then return to initial Y position
The position in the first frame = cameraSpotlightOffPos.
We expected that the camera should just horizontally move to the final position.
Please help us to do that D:
Here's some variable of my Pro Camera 2D settings:
Pro Camera 2D
- FollowX Smoothness = 0.2, FollowY Smoothness = 0.06
- OffsetX = 0, OffsetY = -3
ForwardFocus
- Progressive = false
- Smoothness = 0.2
- Movement Threshold = (0, 0)
- LeftFocus = RightFocus = 0.15
- UpFocus = DownFocus = 0.001
NumericBoundaries
- UseTop = UseBottom = UseLeft = UseRight = true
- SoftBoundaries = true, Softness = 0.5, SoftArea = 0.1
- FollowX Smoothness = 0.2, FollowY Smoothness = 0.06
- OffsetX = 0, OffsetY = -3
ForwardFocus
- Progressive = false
- Smoothness = 0.2
- Movement Threshold = (0, 0)
- LeftFocus = RightFocus = 0.15
- UpFocus = DownFocus = 0.001
NumericBoundaries
- UseTop = UseBottom = UseLeft = UseRight = true
- SoftBoundaries = true, Softness = 0.5, SoftArea = 0.1