Raised This Month: $ Target: $400
 0% 

MOVETYPE_BOUNCE without touching anything


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-15-2012 , 14:44   MOVETYPE_BOUNCE without touching anything
Reply With Quote #1

How do I simulate MOVETYPE_BOUCE if an entity reaches a set origin (for example 500 < x < 900 and 100 < y < 1500)? I want the entity to 'bounce' and go back in reverse direction. I tried executing Ham_Touch but it didn't do anything.
Backstabnoob is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-15-2012 , 14:51   Re: MOVETYPE_BOUNCE without touching anything
Reply With Quote #2

Just reflect their velocity as if they bounced.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-15-2012 , 15:01   Re: MOVETYPE_BOUNCE without touching anything
Reply With Quote #3

Thanks, works
Backstabnoob is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-15-2012 , 15:49   Re: MOVETYPE_BOUNCE without touching anything
Reply With Quote #4

One question: If I reverse the velocity with * -1.0, it goes backwards and doesn't reverse the angle. How would I do that? I was never good with this velocity stuff

Last edited by Backstabnoob; 06-15-2012 at 15:50.
Backstabnoob is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-15-2012 , 16:05   Re: MOVETYPE_BOUNCE without touching anything
Reply With Quote #5

Quote:
Originally Posted by Backstabnoob View Post
One question: If I reverse the velocity with * -1.0, it goes backwards and doesn't reverse the angle. How would I do that? I was never good with this velocity stuff
Subtract the angles from 180 degrees?
__________________
<VeCo> is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-15-2012 , 16:21   Re: MOVETYPE_BOUNCE without touching anything
Reply With Quote #6

More like multiply it by two, but where and how?
Backstabnoob is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-15-2012 , 17:19   Re: MOVETYPE_BOUNCE without touching anything
Reply With Quote #7

Is it always a certain plane it is reflecting from?

If you know the normal of the plane it is reflecting off of, you can do this:
Code:
new Float:velocity[3], Float:normal[3]; new Float:reflected[3]; xs_vec_reflect(velocity, normal, reflected); // set velocity to reflected
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-15-2012 , 20:25   Re: MOVETYPE_BOUNCE without touching anything
Reply With Quote #8

I'm trying to make a sort of virtual wall that's passable by the players but impassable by the entity (soccerjam ball). If the entity touches the origin, it should get reflected.

The box is defined like this:
if( !(1808.0 < Y < 2670.0 ) || !( -2717.0 < X < -1744.0 ) || Z > 100.0 )
// reflect the ball

I tried something with the example you posted but I've been only half successful. It gets reflected only when it wants to and the vector length is somehow twisted (that should be speed if I'm correct) as the ball's speed usually increases when it touches the fake wall.

Here's the code in the ball's think:

Code:
entity_set_float( iEntity, EV_FL_nextthink, halflife_time( ) + 0.05 )         static Float:vOrigin[ 3 ], Float:vBallVelocity[ 3 ]     entity_get_vector( iEntity, EV_VEC_origin, vOrigin )     entity_get_vector( iEntity, EV_VEC_velocity, vBallVelocity )         static iOwner; iOwner = pev( iEntity, pev_iuser1 )     static iSolid; iSolid = pev( iEntity, pev_solid )             if( !( 1808.0 < vOrigin[ 1 ]/*2344*/ < 2670.0 ) || !( -2717.0 < vOrigin[ 0 ]/*2239*/ < -1744.0 ) || vOrigin[ 2 ] > 100.0 )     {         new Float: normal[ 3 ], Float: reflected[ 3 ]                 /* I wanted to decrease the speed here but it doesn't work, it works on Ham_Touch though */         new Float: to_change[ 3 ]         to_change[ 0 ] = vBallVelocity[ 0 ] * 0.85         to_change[ 1 ] = vBallVelocity[ 1 ] * 0.85         to_change[ 2 ] = vBallVelocity[ 2 ] * 0.85                 xs_vec_normalize( vOrigin, normal )                 xs_vec_reflect( to_change, normal, reflected )                     entity_set_vector( iEntity, EV_VEC_velocity, reflected )     }

I'm pretty sure I did a huge mistake somewhere. Please correct me if that's the case as I really don't have a clue on what I'm doing. Vector stuff was never friends with me -.-

Last edited by Backstabnoob; 06-15-2012 at 20:28.
Backstabnoob is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-15-2012 , 21:03   Re: MOVETYPE_BOUNCE without touching anything
Reply With Quote #9

Code:
xs_vec_normalize( vOrigin, normal )

That's not what I meant by a normal. The normal describes the direction a plane's flat side is facing.

How do you want this to bounce? Backwards at where it came from, or as if it hit a wall at an angle?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-16-2012 , 04:54   Re: MOVETYPE_BOUNCE without touching anything
Reply With Quote #10

Exactly as if it would hit a wall (with an angle). Also, do you have an idea on why the speed is getting increased on bounce? Sometimes it just bounces between two planes until it gets stuck and it looks super retarded.

Last edited by Backstabnoob; 06-16-2012 at 05:13.
Backstabnoob is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode