Search Unity

Question beginner problem Help Needed Error CS0029 FPS Game

Discussion in 'Scripting' started by FirstBB8Droid, May 31, 2020.

  1. FirstBB8Droid

    FirstBB8Droid

    Joined:
    May 17, 2020
    Posts:
    39
    I'm making an fps and I'm trying to make a "Tracer like" blink ability and I'm using a tutorial to help, I amd trying to add my own custom input and I went to Edit > Project Setting > Input Manager, I duplicated a random Axis and then set it up so it's named Blinke and I assigned it to the left shift button, I keep on getting an error message that says
    Assets\scripts\Blink.cs(16,13): error CS0029: Cannot implicitly convert type 'float' to 'bool'
    Here's the code
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Blink : MonoBehaviour
    6. {
    7.     public float distance = 5.0f;
    8.     void Start()
    9.     {
    10.        
    11.     }
    12.  
    13.  
    14.     void Update()
    15.     {
    16.         if (Input.GetAxis("Blinke"))
    17.         {
    18.             BlinkForward();
    19.         }
    20.     }
    21.     public void BlinkForward()
    22.     {
    23.         RaycastHit hit;
    24.         Vector3 destination = transform.position + transform.forward * distance;
    25.        
    26.         if (Physics.Linecast(transform.position, destination, out hit))
    27.         {
    28.             destination = transform.position + transform.forward * (hit.distance - 1f);
    29.         }
    30.  
    31.         if (Physics.Raycast(destination, -Vector3.up, out hit))
    32.         {
    33.             destination = hit.point;
    34.             destination.y = 0.5f;
    35.             transform.position = destination;
    36.         }
    37.     }
    38. }
    39.  
     
  2. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    493
    FirstBB8Droid likes this.
  3. FirstBB8Droid

    FirstBB8Droid

    Joined:
    May 17, 2020
    Posts:
    39
    Dextozz likes this.