GDScript... please help me create a movement script I follow every guide and nothing is working!!!

Discussion in 'Java' started by LJthecoder, Jun 25, 2019.

  1. LJthecoder

    LJthecoder

    Joined:
    Jun 25, 2019
    Messages:
    2
    Likes Received:
    0
    please help me create a movement scrip that works for you explain how you did it......
     
    LJthecoder, Jun 25, 2019
    #1
    1. Advertisements

  2. LJthecoder

    John Joe

    Joined:
    Apr 25, 2017
    Messages:
    114
    Likes Received:
    14
    Location:
    Malaysia
    Please post the code you have tried, so we can look for it.
     
    John Joe, Jun 26, 2019
    #2
    1. Advertisements

  3. LJthecoder

    LJthecoder

    Joined:
    Jun 25, 2019
    Messages:
    2
    Likes Received:
    0
    extends KinematicBody
    var gravity = -9.8
    var velocity = Vector3()
    var camera = get_global_transform("/...camera")
    const SPEED = 6
    const ACCELERATION = 3
    const DE_ACCELERATION = 5
    #func _process(delta):
    # # Called every frame. Delta is time since last frame.
    # # Update game logic here.
    # pass
    func _physics_process(delta):
    var dir = Vector3()
    if(Input.is_action_pressed("move_fw")):
    dir += -camera.basis[2]
    if(Input.is_action_pressed("move_bw")):
    dir += camera.basis[2]
    if(Input.is_action_pressed("move_l")):
    dir += -camera.basis[0]
    if(Input.is_action_pressed("move_r")):
    dir += camera.basis[0]

    dir.y = 0
    dir = dir.normalized()

    velocity.y += delta * gravity

    var hv = velocity
    hv.y = 0

    var new_pos = dir * SPEED
    var accel = DE_ACCELERATION

    if (dir.dot(hv) > 0):
    accel = ACCELERATION

    hv = hv.linear_interpolate(new_pos, accel * delta)

    velocity.x = hv.x
    velocity.z = hv.z

    velocity = move_and_slide(velocity, Vector3(0,1,0))
     
    LJthecoder, Jun 27, 2019
    #3
  4. LJthecoder

    John Joe

    Joined:
    Apr 25, 2017
    Messages:
    114
    Likes Received:
    14
    Location:
    Malaysia
    It doesn't looked like Java. What language is that?
     
    John Joe, Jun 27, 2019
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.