Search Unity

Automation of Keypress Code Help

Discussion in 'Scripting' started by melonhead, Jun 14, 2018.

  1. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    how can i make the 2 lines of code below automated so that they are automatically run without having the press xaxis or yaxis keys, if i remove the xaxis or yaxis from the lines i get an error, what do i replace the xaxis and yaxis with in the lines to make them excecute without a keypress, it is driving me mad trying to get this automated

    turnPercent = Mathf.SmoothDamp(turnPercent, xAxis, ref turnVelocity, turnSpeed);

    forcePercent = Mathf.Clamp(Mathf.SmoothDamp(forcePercent, yAxis, ref forceVelocity, forceChangeSpeed), -0.3f, 1f);

    both lines execute perfectly when pressing the axis keys, but i am trying to add these to an ai vehicle and need to remove the need for keypresses

    any help would be gratefully recieved, thank you in advance
    d
     
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    Just set xAxis/yAxis to 1.0f or any other value you want it to have.
     
  3. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    blimey it was so obvious, how stoooopid do i feel now, thank you