I’m working on a Third Person cover system shooter and currently I’m working on the cover functionality.
_
I have two scripts: a character controller script and a cover detection script.
_
I have code on my cover detection script that detects cover with a raycast and creates a raycasthit.point at the point of collision with the collider. I also have a float on the same script called coverMoveSpeed that I’d like to multiply against time.delta so the player doesn’t instantly snap to the cover, instead I’d like it to smoothly move there depending on the coverMoveSpeed float.
_
In my head I thought it would be as simple as this:
bool coverKey = Input.GetButton("Cover");
if (coverKey & coverMovement.canCover)
{
transform.position = coverMovement.hit.point + coverMoveSpeed * Time.deltaTime;
}
else
{
}
Here’s my implementation
//on my cover detect script
public float coverMoveSpeed = 3.0f;
//Here's my character controller script
bool coverKey = Input.GetButton("Cover");
if (coverKey & coverMovement.canCover)
{
transform.position = coverMovement.hit.point;
}
else
{
}
_
However it doesnt compile, I know I’m close so I’m turning to the unity forums once again!
_
beep beep “Paging Dr. Stark” @LCStark