follow the inclination of the floor


I ve created a character which is moving on the scene floor, but stay always parallele to the horizont line even if the floor has a 45° inclination.
It should follow the inclination of the floor.

I would like to solve this problem with Ray sensors. As soon as one of these 2 Ray sensors (in green) detecting an inclined floor, it should make inclining/rotating the Rigs of the character.

Is there any kind of logic brick with which is possible to apply a rotation or an angle value to the Rig or objet ?

Thanks in advance for any tipps


I think people are too lazy to answer this lol, basically there is no way you can align an object to the face of a normal using logic bricks.

Tip: Use Python!

You can’t align a single face, but you can align an object, and in this case the skateboard could be that object.

thank you rossblenderart!

it is simple and it works very good.
the problem is to know which logic bricks are the right one :D.
i’ve made a little test blend file.
(see attached)


skating-in-the-bowl.blend (502 KB)

I have implemented my game, using the actuator “constraint” and it works.

But due to the fact that I am applying a linear velocity to ride forward, my skater doesn’t stop immediatly, like before.
I think have to implement further and make a kind of breaks.

Sorry the last video link is dead. Here new one:

Interesting character, though. Mr. Burger-feet. :slight_smile:

You could use servo motion to stop him.
Keyboard (click All and Invert) - And - Servo Motion (default)
So when the player is not pressing a key, he stops. (maybe enable Z so he cant freeze midair)

thank you for your comments!
I’ve made the modifications (thanks Rossblenderart) with the motion servo and adapted the setup of the skater, but as I want to keep the camera subjective view / mouse look script, I still have some troubles.

See this video capture :

The skater is spinning when he reachs the top of the looping ramp.
I guess the cone local axis are still aligning on the global axis.

Is it possible to lock the rotation of the local X axis of the cone to stop its rotation ?

The skater is setted like this:

If any ideas, thanks in advance !

I’ve tried to link the cone (as a rigid body, ghost) to the collider with a rigidbody joint constraint generic 6DOF (remaining only the Z axis rotation free) but the link is even so fragile and doesn’t stay in its vertical position (along local Z axis). The arrow is not strong enough to track the cone, when the skater is reaching the top of the looping ramp.

Maybe the solution is to copy the local orientation coordinates of the collider XYZ axis and paste them on the local orientation coordinates of the cone XYZ axis, in order to force the cone to be aligned on the collider ?
Lock the local rotation X axis of the cone would be more simple, but I don’t know if it is possible ? (also through python script)

Wow, you go through so much trouble for this to work in SCA.

You should just switch to python, I believe you’ll find it’s not as hard as you think. Especially compared to what you’ve tried to set up and grasp with logic bricks.

Hi Kheetor,
it’s maybe true that python is not that difficult to manage. But I would like to realise a (simple) game with the possibilities that allow the logic bricks. It seems that sometimes the power of logic brick is underestimated, like the brilliant video-tutorial of Rossblenderart demonstrate it.
Of course if a bit script is needed I would script too.

So by the way if there is no logic brick solution, how would look like the python script to lock the cone local rotation axis X ? :smiley:

The great aspect of logic bricks is that you can explain how works a (simple) video game to yourself and anybody else who doesn’t have any idea how it works. And it is also great for beginers like me. It’s more concrete, and quite simple, plug and unplug, a bit like a guitar player does with its effects and filters pedals.

but maybe I’ll have to script in python soon, anyway.

I’ve come late to your party, but does this blend help you any? Press up to go forward.


defy_gravity_logic.blend (460 KB)

Here’s SolarLune’s response from another thread (untested):

To convert an orientation matrix into a euler (X, Y, and Z) angled rotation, you can use:

e = obj.orientation.to_euler()

Set the values with:

[I]e.x = 3.1415

And then reset the orientation:

obj.orientation = e [/I]

great video, funny sandwich legs:D

thank you kheetor,
I think need to follow some Python tutorials to use this. :smiley:

You just need a reference for “obj” used there. You could try this (untested):

import bge

cont = bge.logic.getCurrentController()
obj = cont.owner
e =  obj.orientation.to_euler()
e.x = 3.1415
obj.orientation = e

I try this (my first script in BGE, yeearr!), but it doesn’t work :eyebrowlift2:

import bge

def main():
    cont = bge.logic.getCurrentController()
    cone = cont.owner
    cone.localOrientation[1] = 0

The logic bricks attached to my cone (please look at the picture in my previous comments):
Always sensor ----------- Python actuator (my script)

my cone ist dynamic-gohst objet and it is linked to my collider through a rigid body joint.

I would like to lock the rotation of my cone on its local X axis.
What am I doing wrong :smiley: ?

Thank you for your good ideas :RocknRoll:

Hi kheetor,
I 've just noticed that you post your script hat the same time as I posted my last comment.
Thank you, I 'll try your script

You know that’s not bad. :slight_smile:

But there is your first lesson: python lists are actually referenced starting from 0 rather than 1. So x=0, y=1 and z=2 in this case.

Here’s the second lesson: the default orientation is actually in hard to grasp vector format. The first entry on the list (or actually it’s a matrix) returns the X axis vector, the second the Y axis vector and third the Z axis vector. You can’t edit them properly without some vector math as you need to recalculate all vectors properly if you want to adjust any. Editing single vector or axis only results in distorted object.

That’s why it’s convenient for this purpose to convert to XYZ Euler before assigning the desired rotation. (you can view different orientation models in model view side panel -> Transform -> Roation drop down menu.)