This isn't a real physics engine, so it might not belong in this forum, but this is the closest I can think of regarding how it works.
Let's say for a minute that I have a ball. Not an ordinary ball - just a cylinder that's flat on top and on the bottom, but is round when you look at it from the top. It moves around in the level and can collide with other objects. When it collides, it bounces.
And it works great - on angles facing the right. For all the other angles, instead of bouncing off of the wall, the ball sticks to it! This is my code. I've tried everything humanly possible to fix it, but nothing works.
PS: I made a post earlier and got a reply saying that BOUNCE is an xyz, not a pan-tilt-roll. I've checked the manual and it is in fact an angle, not a position.
Code:
function ball_event
{
my_motion.x *= 0.5;
my_motion.y *= 0.5;
my_motion.z *= 0.5;
if(bounce.pan < 90) && (bounce.pan > -90)
{
my_motion.x += cos(bounce.pan)*(vec_length(my_motion));
my_motion.y += sin(bounce.pan)*(vec_length(my_motion));
}
else
{
my_motion.x -= cos(bounce.pan)*(vec_length(my_motion));
my_motion.y -= sin(bounce.pan)*(vec_length(my_motion));
}
}
action ball
{
ball_object = my;
my.event = ball_event;
my.enable_block = on;
my.enable_entity = on;
var space_on;
while(1)
{
proc_late();
ball_pan1.pos_x = int(my.x) - 33;
ball_pan1.pos_y = table_panel.pos_y + (2048 - int(my.y)) - 33;
my_motion.z = 0;
my_motion.y -= 0.25 * time;
if(key_space) && (space_on == off)
{
space_on = on;
my_motion.x -= 15 * time;
}
if(!key_space)
{
space_on = off;
}
c_move(my, nullvector, my_motion, ignore_passents+activate_trigger+use_aabb);
if(my.x < 0){my.x = 0;}
if(my.x > 1024){my.x = 1024;}
if(my.y < 0){my.y = 0;}
if(my.y > 2048){my.y = 2048;}
wait(1);
}
}