+1 vote

I have been trying to wright a simple 3d controller for a game in the new 3.0 Alpha (I had used v.2 before, but 3d and networking were not its strongest suits), and while trying to implement a jumping mechanism, I noticed that the isonfloor() function was always printing out "false" in the debugger. So I was wondering if there is anything I must do in particular before I use this function, like set the static body as a "floor" somewhere or something of the sort. Here is a google drive link to the project. https://drive.google.com/open?id=0B7tbusHfoTBvajFTSjNiTWN0Slk

PS. I added a simple gui text that is supposed to display the isonfloor() value of the character.

in Engine by (88 points)

1 Answer

+1 vote

You need to move_and_slide first (check the Kinematic Character 3D demo on master demos repo).

Also try a more recent build because the result of move have some bugs on the alpha.

by (7,868 points)

Oh, I was already using "moveandslide(Vector3())", mind explaining further?

As for builds, I don't build them on my own, and fixnum seems broken..

The method move_and_slide have a couple of parameters, the 2nd one is the floor normal, if you set it, like (0,1,0) [pointing up on Y], then when checking it should say true if is the close to the normal (including slope tolerance).

move_and_slide(motion,floor_normal)

The last parameter is important too if you want to allow some specific angles to be taken as "floor" (like on slopes or irregular floor), by default is around 45ยบ.

Look here or the internal help for a bit of information that may give you a hint on the full usage (still no detailed description, this method may change again before 3.0):
http://docs.godotengine.org/en/latest/classes/class_kinematicbody.html#class-kinematicbody-move-and-slide

ps: I have seen discussions about move too so be prepared for more changes.

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.