3 registered members (NewbieZorro, TipmyPip, 1 invisible),
19,045
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Spherical gravity
[Re: alibaba]
#367805
04/18/11 16:51
04/18/11 16:51
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
One more Question Julz, sorry that i am asking that much. No worries  I'm not normally very helpful around here but these kind of problems really interest me (hence my original quaternion and alignToVec contributions). If I didn't want to help out I'd leave it for someone else to answer. It's hard to define an absolute pan orientation when an object's local z axis is changing. I think the best approach is to find a vector that represents the direction you want the object to face, and then rotate around one axis to face that vector. Here's a slightly changed action le():
action le()
{
var relTilt = 0;
player=me;
VECTOR temp;
while(1)
{
gravitz();
if(key_space&&!oben)
walk_speed.z=5;
my.skill9=100*(key_k-key_l); //Target angle/ 100 or -100
alignToVec(my.pan, normal, vector(0, 0, 1), time_step);
vec_for_angle(temp, vector(my.skill9, 0, 0)); // get a vector pointing where we want to point
vec_rotateback(temp, my.pan); // find that vector relative to the entity's current orientation
vec_to_angle(temp, temp); // convert to a rotation
c_rotate(my, vector(ang(temp.x*0.9*time_step),0,0),GLIDE|USE_AXISR);
c_move(my,vector((key_w-key_s)*20*time_step,(key_a-key_d)*20*time_step,walk_speed.z),nullvector,GLIDE | IGNORE_PASSABLE|IGNORE_FLAG2);
wait(1);
}
}
I don't think it's a good idea that you use c_rotate and change the entity's orientation directly (passing my.pan to alignToVec). The latter doesn't perform any collision detection, and the former is unnecessarily slow if your objects have complete spherical symmetry (max_x = max_y = max_z = -min_x = -min_y = -min_z). I did it your way anyway because I wanted to change your code as little as necessary. I hope that makes sense. Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Spherical gravity
[Re: JibbSmart]
#367808
04/18/11 17:23
04/18/11 17:23
|
Joined: May 2008
Posts: 2,113 NRW/Germany
alibaba
OP
Expert
|
OP
Expert
Joined: May 2008
Posts: 2,113
NRW/Germany
|
You are awesome!  The object isn´t jerking around now, but if i´m a bit higher then the object rotates in opposite. so if i press k the the object turns right. I hope you understand what i mean. If you want you can try it yourself.
|
|
|
Re: Spherical gravity
[Re: alibaba]
#367815
04/18/11 18:59
04/18/11 18:59
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Yes, the object is trying to face the given pan as if it is rotated around the world's z axis.
I'm not sure how to get the behaviour you want. Perhaps someone else can try, or I might put more time into it later, but I've got other things I need to get done today.
Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
|