Search Unity

Unity3D How to move ball left & right only?

Discussion in 'Editor & General Support' started by Unity-Student0, Apr 28, 2022.

  1. Unity-Student0

    Unity-Student0

    Joined:
    Aug 10, 2020
    Posts:
    263
    Hello,

    Please be informed that my code is already created and I want it so that after I move the ball left or right, it doesn't just shoot straight forward. I want it so that I can either lift my finger, then touch it again OR move it upwards (as in forward) and shoot the ball forward. Please see the screenshot and the code so you know what I mean. Please do not just throw some touch finger code as I might not understand how it can be fitted into my existing code. I'm also not an expert and might not understand how this can be done. Any explanation anyone can give to me to know how it works would be really kind and nice. I look forward to extra effort made.
     

    Attached Files:

  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,048
    Dont use addfoce, just change the velocity. Then you can keep the forward speed constant and lerp to your finger on the other axis
     
  3. Unity-Student0

    Unity-Student0

    Joined:
    Aug 10, 2020
    Posts:
    263
    @JeffDUnity3D,
    Where do I find lerp code? Can you help? I'm unsure what I'm doing.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Google! Perhaps try a search like "unity lerp documentation" followed by "unity lerp tutorial".
     
    DevDunk likes this.