0 votes

I'm using zylanns height terrain plugin: https://github.com/Zylann/godot_heightmap_plugin

I tried moving on a simple square (staticbody, meshinstance, collisionshape) with a sphere (kineticbody, meshinstance, collisionshape) and that worked fine but once I try the same thing on a HTerrain it just doesn't work. The sphere does not move on the terrain. Do I need to change the collision layers or mask or anything?

The code I'm using to move the sphere:

extends KinematicBody

const gravity = -9.8
var velocity = Vector3()

const SPEED = 6
const ACCELERATION = 3
const DE_ACCELERATION = 5

var camera

func _ready():
  camera = get_node("Camera").get_global_transform()

func _physics_process(delta):
  var dir = Vector3()

if(Input.is_action_pressed("ui_up")):
    dir += -camera.basis[2]

if(Input.is_action_pressed("ui_down")):
    dir += camera.basis[2]

if(Input.is_action_pressed("ui_left")):
    dir += -camera.basis[0]

if(Input.is_action_pressed("ui_right")):
    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))

The scene being played:
scene

The sphere being moved:
player

Sphere that's stuck:
stuck player

I'm using the latest godot version (3.2.2) and downloaded the addon from the master branch.

in Engine by (19 points)

Try playing with the collision of the sphere, increase its collision margin. Make a new one just in case. Don't scale it, resize it with the round handles.

Thank you for trying to help, but it has been solved already. https://github.com/Zylann/godot_heightmap_plugin/issues/217

1 Answer

0 votes
Best answer
by (19 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.