|
Post by davidc02 on Apr 24, 2020 2:59:44 GMT
So I have this
if (Input.GetAxis("RightVertical") != 0)
{
ProCamera2D.ApplyInfluence(new Vector2(0, Input.GetAxis("RightVertical") * verticalInfluence * -1));
}
but when I let go the stick the camera abruptly jumps to the original position, if I disable Limit Distance this doesn't happen, but I need limit distance.
I added this
ProCamera2D.GetComponent<ProCamera2DLimitDistance>().enabled = false;
but then if I enable it again when equals 0, the same issue happens.
Is there any method that says "there's still influence", or "camera is not being influenced anymore", or something along those lines that would allow me to temporarily override Limit Distance?
|
|
|
Post by davidc02 on May 19, 2020 23:57:26 GMT
What I basically need is to temporarily disable Limit Distance when I press R3 and enable it again when there's no longer an influence on the camera.
I can't however enable it as soon as I let go R3, it needs to be after the influence is over.
|
|
|
Post by Luís Pedro Fonseca on May 20, 2020 21:32:34 GMT
Hi davidc02, not sure I follow this, but you might want to experiment with tweening those values (with DOTween for example), instead of abruptly enabling/disabling the extension.
|
|
|
Post by davidc02 on May 22, 2020 19:00:43 GMT
That's what I thought. Was just wondering if this was already done by you somewhere.
The goal is to apply an influence to the Camera when I move R3 around, as I do (i.e. as I tilt R3 on agmepad) I want to disable Limit Distance so I can influence the camera beyond the limits of the room.
Is there any method on PC2D that shows when the influence is over?
|
|
|
Post by Luís Pedro Fonseca on May 23, 2020 8:46:36 GMT
davidc02 There's a "InfluencesSum" property that you can check if it's different than zero.
|
|
|
Post by davidc02 on Feb 8, 2021 2:00:10 GMT
This is what I ended up doing.
private void Influence()
{ //Calculate Influence of Right Stick var currentInfluence = new Vector2(horizontalInfluence, verticalInfluence) * _influenceAxis; //_influenceAxis = InputHandler.GetAxis(StickType.Right) is inside Update() and is Vector2.
//Check if Influece is zero
if (PC2DCameraUtils.Instance.ProCamera2D.InfluencesSum == Vector3.zero)
{
noInfluenceTimer -= Time.deltaTime;
if (noInfluenceTimer < 0) //after certain time of influence beeing zero {
PC2DCameraUtils.Instance.GetComponent<ProCamera2DLimitDistance>().enabled = true; //enable camera limits again
}
} else
{
PC2DCameraUtils.Instance.GetComponent<ProCamera2DLimitDistance>().enabled = false; //disable camera limits while there's influence
noInfluenceTimer = _noInfluenceTimer; //reset timer
}
PC2DCameraUtils.Instance.Influence = currentInfluence; //apply influence to camera
}
|
|