Oh, walking on spheres? It is very hard to code this. I tryed it several times with some methods.
For exaple i used Sin, cos, asin etc. to get the angele of the player. The big problem are the euler-angles. It is possible to turn the player that he stands on the sphere in every position, but you can't turn the direction very easily.
I think it is a scripting problem.
Ah, you have A6? Then the collision is no problem. But if you try it with A5 you have a big problem with the box-collision system.
Code:
// sphere2.wdl
var video_mode = 8;
var video_depth = 16;
string sph2 = <sphere2.wmb>;
entity* player01;
entity* gem1;
entity* gem2;
var speed[3];
var force[3];
var tilt_Gegenkathete;
var roll_Gegenkathete;
var tilt_Hypothenuse;
var roll_Hypothenuse;
var nil[3] = 0,0,0; //This is the origin of the sphere, to make it easyer it is 000
var another[3];
var tilt_angle1;
var roll_angle1;
string deb1 = "Hallo";
string deb2 = "Hallo";
String deb3 = "Hallo";
String deb4 = "Hallo";
font ar24 = "arial",1,24;
var runtime;
text debug
{
font = ar24;
pos_x = 0;
pos_y = 0;
strings = 4;
string = deb1,deb2,deb3,deb4;
flags = visible;
layer = 1;
}
function main
{
bg_color.red = 1;
level_load(sph2);
}
action gem_1
{
gem1 = my;
}
action gem_2
{
gem2 = my;
}
action set_name
{
my.fat = 0;
my.narrow = 0;
my.polygon = 1;
player01 = my;
wait(1);
while(1)
{
if(key_w == 0)&&(key_s == 0){force.x = 0;}else{if(key_w == 1){force.x = 5;}if(key_s == 1){force.x = -5;}}
if(key_a == 0)&&(key_d == 0){force.y = 0;}else{if(key_a == 1){force.y = 5;}if(key_d == 1){force.y = -5;}}
if(key_q == 1){speed.z = -1;}else{speed.z = 0;}
math();
c_move(me,force,speed,glide);
wait(1);
}
}
function math
{
vec_set(speed,player01.pos);
vec_inverse(speed);
vec_scale(speed,0.02);
gem2.x = 0;
gem2.y = 0;
if(player01.z > 0)
{
tilt_Gegenkathete = gem1.x - player01.x ;
tilt_Hypothenuse = vec_dist(player01.pos,nil);
tilt_angle1 = tilt_Gegenkathete / tilt_Hypothenuse;
tilt_angle1 = asin(tilt_angle1);
if(tilt_angle1 < 0){tilt_angle1 = 360 + tilt_angle1;}
Str_for_num(deb1,tilt_angle1);
player01.tilt = tilt_angle1;
roll_Gegenkathete = gem1.y - player01.y;
roll_Hypothenuse = vec_dist(player01.pos,nil);
roll_angle1 = roll_Gegenkathete / roll_Hypothenuse;
roll_angle1 = asin(roll_angle1);
if(roll_angle1 < 0){roll_angle1 = 360 + roll_angle1;}
Str_for_num(deb2,roll_angle1);
player01.roll = roll_angle1;
}
if(player01.z < 0)
{
tilt_Gegenkathete = gem1.x + player01.x;
tilt_Hypothenuse = vec_dist(player01.pos,nil);
tilt_angle1 = tilt_Gegenkathete / tilt_Hypothenuse;
tilt_angle1 = asin(tilt_angle1);
if(tilt_angle1 > 0)&&(tilt_angle1 != 0){tilt_angle1 = 180 + tilt_angle1;}else{if(tilt_angle1 != 0){tilt_angle1 = 180 + tilt_angle1;}}
Str_for_num(deb1,tilt_angle1);
player01.tilt = tilt_angle1;
roll_Gegenkathete = gem1.y - player01.y;
roll_Hypothenuse = vec_dist(player01.pos,nil);
roll_angle1 = roll_Gegenkathete / roll_Hypothenuse;
roll_angle1 = asin(roll_angle1);
if(roll_angle1 < 0)&&(roll_angle1 != 0){roll_angle1 = 360 + roll_angle1;}else{if(roll_angle1 != 0){roll_angle1 = 360 - roll_angle1;}}
player01.roll = roll_angle1;
Str_for_num(deb2,roll_angle1);
}
}
var look_at1[3];
var look_at2[3];
var turn[3];
var go[3];
var tilt_G;
var tilt_H;
var tilt_a;
entity* mod;
action new
{
mod = my;
my.narrow = 0;
my.fat = 0;
my.polygon = 1;
wait(1);
while(1)
{
if(key_f == 1){turn.pan = 5;}else{if(key_h == 1){turn.pan = -5;}else{turn.pan = 0;}}
if(key_t == 1){go.x = 1;}else{go.x = 0;}
math2();
c_move(mod,go,nullvector,null);
wait(1);
}
}
function math2
{
if(player01.z > 0)
{
tilt_G = gem1.x - mod.x ;
tilt_H = vec_dist(mod.pos,nil);
tilt_a = tilt_G / tilt_H;
tilt_a = asin(tilt_a);
}
vec_for_vertex(look_at1,mod,688);
vec_for_vertex(look_at2,mod,689);
vec_sub(look_at2,look_at1);
turn.tilt = tilt_a;
vec_rotate(look_at2,turn);
vec_to_angle(mod.pan,look_at2);
}
Here a small example of my thinking direction. I give it up to comment it. it works not very good. It is just an idea.
edit:
I understand: you are using A5. If you use a model as a sphere, not only the scripting even the collision is a problem. You can't use poly-collision in A5.
If you are trying to use a block sphere, it is possible to chack the normals of the block under the player. So you can turn the player around.
The big point is to get a working gravity code.