Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,426 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Bounce without changing angle... #170670
12/02/07 18:47
12/02/07 18:47
Joined: Apr 2006
Posts: 36
P
pwy Offline OP
Newbie
pwy  Offline OP
Newbie
P

Joined: Apr 2006
Posts: 36
Hello,
I have 3DGS 7.

OK. This is driving me nuts! How do I make a character bounce "away" from an enemy when hit?

I've read quite a bit about "bounce" and "vec_to_angle"--but, I don't want the player's angle/pan to change. If the enemy hits the front, back or side of the player, then shoot the player in that direction. Does that make since?


Thanks in advance for any help. I could use a point in the right direction...
"No pun intended"

Re: Bounce without changing angle... [Re: pwy] #170671
12/03/07 14:36
12/03/07 14:36
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
bounce is a direction-vector, just set the move-direction of the entity to the (scaled)bounce vector

Re: Bounce without changing angle... [Re: Scorpion] #170672
12/03/07 16:43
12/03/07 16:43
Joined: Apr 2006
Posts: 36
P
pwy Offline OP
Newbie
pwy  Offline OP
Newbie
P

Joined: Apr 2006
Posts: 36
I've tried a million ways. I can't get it to work.
I have very limited vector math skills.

Here's one of the ways I tried doing what you said:
...
if( bounce.x != 0 ){
vec_scale( bounce.x , 5 );
vec_set( playerMove.x , bounce.x );
}
...
c_move( my , playerMove , nullvector , etc.. );


Don't laugh.

Re: Bounce without changing angle... [Re: pwy] #170673
12/03/07 16:49
12/03/07 16:49
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
I dont want to script anything right now , but I'd suggest you another way :
On collision , store player pan and change it to the bounce direction for relative movement (not absolute!). After that , retreive the original player pan. Your entity will appear to be always facing the same angle and move in a diffrent direction. Another suggestion is , decrease the diffrence between the two pan angles after a collision with bounce and you'll get a spherical movement , as if the force pushing the player in another way is decreasing.
You could do this pure mathematicaly with vectors & forces , but sometimes the 'ordinary' way isnt the easyest (I'm no good at math!)


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Bounce without changing angle... [Re: EpsiloN] #170674
12/03/07 21:50
12/03/07 21:50
Joined: Apr 2006
Posts: 36
P
pwy Offline OP
Newbie
pwy  Offline OP
Newbie
P

Joined: Apr 2006
Posts: 36
Man, I am struggling with this...
I got the player ( aka Lana ) to bounce back. But it still doesn't take into account if she is facing away from the enemy when she is attacked. And sometimes it's totally unpredictable...

UHG~

Here's my messy code:

CODE-----------------------------------
while( my ){

my.pan = angle;

v += speed * time_frame;

if( v >= 30 ){ v = 30; }
if( v <= 0 ){ v = 0; }

//lana was hit
if( my.skill1 == 1 ){
v = 30;
b = -0.62; //bounce amount
}else{
b = 1;
}//end if

dx = (v*b) * cos( angle );
dy = (v*b) * sin( angle );

lanaMove.x = dx * time_frame;
lanaMove.y = dy * time_frame;
lanaMove.z = 0;

c_move( lana , nullvector , vector( lanaMove.x , lanaMove.y , lanaMove.z ) , GLIDE | IGNORE_PASSABLE );

wait( 1 );
}//end while
CODE-----------------------------------

Re: Bounce without changing angle... [Re: pwy] #170675
12/04/07 02:59
12/04/07 02:59
Joined: Apr 2006
Posts: 36
P
pwy Offline OP
Newbie
pwy  Offline OP
Newbie
P

Joined: Apr 2006
Posts: 36
OK, That last code was pointless obviously.

This seems to work. But, she goes shooting off the screen way to quickly! Any ideas? Thanks for any help you may have.

CODE------------------------------------------------------

...
var bounceDir;
...

function lanaHit(){

if( event_type == EVENT_IMPACT || event_type == EVENT_ENTITY ){

bounceDir = bounce;

}//end if

}//end function





//Action-------------
ACTION lana_action(){
lana = my;
clip_size = 0;

wait( 1 );
c_setminmax( my );

my.ENABLE_ENTITY = on;
my.ENABLE_IMPACT = on;
my.ENABLE_SCAN = on;
my.x = 0;
my.y = 0;
my.z = 0;
my.skill1 = 0; //isHit
my.event = lanaHit;


while( my ){

if( my.skill1 == 0 ){ //is not hit
lanaMove.x = speed;
lanaMove.y = 0;
lanaMove.z = 0;
}else{
vec_scale( bounceDir , 2 );
vec_set( lanaMove , bounceDir );
}//end if


c_move( my , lanaMove , nullvector , GLIDE | IGNORE_PASSABLE );

c_scan( my.x , my.pan , vector( 360 , 180 , 360 ) , SCAN_LIMIT | IGNORE_ME );

wait( 1 );
}//end while
}//end action
//Action------------
CODE------------------------------------------------------

Re: Bounce without changing angle... [Re: pwy] #170676
12/04/07 07:51
12/04/07 07:51
Joined: Aug 2005
Posts: 312
Sweden
tindust Offline
Senior Member
tindust  Offline
Senior Member

Joined: Aug 2005
Posts: 312
Sweden
Not to make things more complicated, but if you want a slower, more "realistic" bounce you could make lana a physics ent temporarily or if she already is, increase the inertia during the bounce.
cheers

Re: Bounce without changing angle... [Re: tindust] #170677
12/04/07 13:26
12/04/07 13:26
Joined: Apr 2006
Posts: 36
P
pwy Offline OP
Newbie
pwy  Offline OP
Newbie
P

Joined: Apr 2006
Posts: 36
Thanks tindust,
I'll give it a shot.

Re: Bounce without changing angle... [Re: pwy] #170678
12/04/07 15:12
12/04/07 15:12
Joined: Apr 2006
Posts: 36
P
pwy Offline OP
Newbie
pwy  Offline OP
Newbie
P

Joined: Apr 2006
Posts: 36
Actually. That's no good. She bounces all over the place.
I'd be happy if I could just get her to bounce away real quick, but not so far away. It doesn't have to look realistic. Something quick would be fine, just not shooting her off the level. LOL

Is there a way to tone down the code I wrote in my last post? A way to make her not shoot off the level at light speed?


Thanks for all the help so far...

Re: Bounce without changing angle... [Re: pwy] #170679
12/04/07 15:37
12/04/07 15:37
Joined: Apr 2006
Posts: 36
P
pwy Offline OP
Newbie
pwy  Offline OP
Newbie
P

Joined: Apr 2006
Posts: 36
Alrighty,
I think I got it. I used:

...
vec_normalize( bounceDir , 2 );
vec_set( lanaMove , bounceDir );
...

That seems to give me the effect I want.
But, it's still a little unpredictable when she turns or isn't moving...


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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