Search Unity

Blink Ability Problem

Discussion in 'Scripting' started by peepercreeper, Jan 18, 2019.

  1. peepercreeper

    peepercreeper

    Joined:
    Jan 14, 2019
    Posts:
    2
    So i have this blink script that works just fine but the only problem is it doesnt go up ramps it stops the teleport when it hits a ramp that you can normally walk up without teleporting, and i need to find a way to be able to change the max ramp angle you can blink upwards on in the editor, can some provide help with this problem?

    here is the script:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Blink : MonoBehaviour {
    public float BlinkDist = 2.5f;
    private bool ASD;
    private int Charge = 3;
    public float Recharge = 3;
    public int RechargeLim = 4;
    void Start(){
    Recharge = RechargeLim;
    }
    void Update () {
    ASD = false;
    if(Charge <= 2){
    Recharge = Recharge - Time.deltaTime;
    if(Recharge <= 0){
    Charge++;
    Recharge = RechargeLim;
    }
    }
    if(Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D)){
    ASD = true;
    }
    if(Charge >= 1){
    if(Input.GetKeyDown(KeyCode.E) && Input.GetKey(KeyCode.D)){
    transform.Translate(Vector3.right * BlinkDist);
    Charge--;
    }
    if(Input.GetKeyDown(KeyCode.E) && Input.GetKey(KeyCode.S)){
    transform.Translate(-Vector3.forward * BlinkDist);
    Charge--;
    }
    if(Input.GetKeyDown(KeyCode.E) && Input.GetKey(KeyCode.A)){
    transform.Translate(-Vector3.right * BlinkDist);
    Charge--;
    }
    if(Input.GetKeyDown(KeyCode.E)){
    if(ASD == false){
    transform.Translate(Vector3.forward * BlinkDist);
    Charge--;
    }
    }
    }
    }
    }
     

    Attached Files: