bulletproofpancake / GAMEPROJ2

0 stars 0 forks source link

Snap Movement Rework #36

Open bulletproofpancake opened 3 years ago

bulletproofpancake commented 3 years ago

movement

Sample Code

    // Bastahan lang to, di ko pa nasusubukan,  paedit na lang XD
    // Sa car controller script
    public List<Transform> snapLocations;
    public int currentSnap;

    Update(){
        if(Input.GetKeyDown(KeyCode.A)){
            //Check kung di labis
            if(currentSnap < 0) return;
            currentSnap--;
            //Dito magtitilt yung jeep
            PlayAnimation("TiltedLeft");
            jeepPosition = Vector3.Lerp(jeepPosition, new Vector3 (snapLocations[currentSnap].x, jeepPosition.y,jeepPosition.z), Time.deltaTime*moveSpeed);
            //Pag naka snap na, balik na sa normal yung jeep
            if(jeepPosition == snapLocations[currentSnap]){
                PlayAnimation("Default")
            }
        }
        if(Input.GetKeyDown(KeyCode.D)){
            //Check kung di labis
            if(currentSnap > snapLocations.Count) return;
            currentSnap++;
            //Dito magtitilt yung jeep
            PlayAnimation("TiltedRight");
            jeepPosition = Vector3.Lerp(jeepPosition, new Vector3 (snapLocations[currentSnap].x, jeepPosition.y,jeepPosition.z), Time.deltaTime*moveSpeed);
            //Pag naka snap na, balik na sa normal yung jeep
            if(jeepPosition == snapLocations[currentSnap]){
                PlayAnimation("Default")
            }
        }

    }
bulletproofpancake commented 3 years ago

Yung animations na TiltedLeft at TiltedRight gawa na lang siguro sa animator ng frame na naka rotate yung jeep sa z-axis ng 45deg, tas yung default ay yung normal orientation