Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,055 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
bounce #103978
12/25/06 18:10
12/25/06 18:10
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Im using this code:

Code:

function _ball_event()
{
vec_to_angle(me.pan, bounce);
}

action aBall
{
my.enable_block=on;
my.enable_entity=on;
my.event=_ball_event;
.....
.....
.....

while(1)
{
c_move(me, v3Movement, nullvector, glide);
wait(1);
}
}




The ball bouces off but pretty strange.



(hope you see what I mean The thin line is the way my ball flys)


So this is not the right bounce, isnt it?

Can someone please tell me how to do it correctly?


thx nipx

Re: bounce [Re: nipx] #103979
12/25/06 23:22
12/25/06 23:22
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
This simple code works for me:

Code:


var ball_speed[3];

function ball_hit()
{
if(event_type == event_block)
{
vec_to_angle(my.pan, bounce);
}
}

action bouncingBall
{
my.enable_block = on;
my.event = ball_hit;

while(1)
{
ball_speed.x = key_1 * 25 * time_step;
ball_speed.y = key_2 * 25 * time_step;
ball_speed.z = key_3 * 25 * time_step;
c_move(my, ball_speed, nullvector, glide);
wait(1);
}
}




Re: bounce [Re: demiGod] #103980
12/26/06 12:52
12/26/06 12:52
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
It works but not well

When I use 1 the ball bounces off correctly

With 2 not It starts gliding along the wall instead of bouncing



Does your ball do that too? I tested it on 2 computers and its always the same.


thx nipx

Re: bounce [Re: nipx] #103981
12/26/06 13:11
12/26/06 13:11
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
The code above its only for test purposes using that keys for input changing the ball_speed vector (x,y,z axis movement). If you are constantly pressing the keys the ball cant bounce because there is always a force applied on it against the wall. I didnt test but if you apply a force to the ball like ball_speed.x = 50, ball_speed.y = 80, ball_speed.z = 0 for example:

function apply_force()
{
ball_speed.x = 50;
ball_speed.y = 80;
ball_speed.z = 0;
}

on_z = apply_force;

may it will work. Hope it helps.

Re: bounce [Re: demiGod] #103982
12/26/06 13:25
12/26/06 13:25
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Quote:

cant bounce because there is always a force applied on it against the wall.




Right I didnt think about that

Anyway it still doesnt bounce as I want.



You see it still glides. But when it hits the upper wall its correct.


thx nipx

Re: bounce [Re: nipx] #103983
12/26/06 17:05
12/26/06 17:05
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Problem solved.

We were both wrong


Because vec_to_angle(my.pan, bounce) change the pan and we use reldist we dont need Movement.y.
Movement.x is enough.



nipx

Re: bounce [Re: nipx] #103984
12/26/06 17:15
12/26/06 17:15
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
Well, i am not sure the problem its solved that way...
If you want try this code:

Code:


function ball_hit()
{
if(event_type == event_block)
{
vec_set(my.skill1, bounce);
}
}


action bouncingBall
{
my.enable_block = on;
my.event = ball_hit;
vec_set(my.skill1,vector(12*time_step,8*time_step,2*time_step));
while(1)
{
c_move(my,my.skill1,nullvector,glide);
wait(1);
}
}





Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1