[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Reversing the angles of an entity

Reversing the angles of an entity

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Reversing the angles of an entity

Postby DusterdooSmock » Tue Sep 27, 2011 8:17 pm

Alright, is there a way to reverse the angles of an entity?
IE: projectile flies at a wall, when it hits the wall, its direction is reversed and it fies back towards where it came from?
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Re: Reversing the angles of an entity

Postby Spike » Tue Sep 27, 2011 8:58 pm

newvel = oldvel - (normal * ((oldvel*normal) * 2));

will reflect a direction/velocity vector by a normal.
you can bounce an angle by using makevectors/vectoangles to convert that angle into a regular vector and back, though you'd need extensions to retain the roll.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Reversing the angles of an entity

Postby necros » Wed Sep 28, 2011 12:48 am

Spike's entirely code is correct. however, if you want to literally bounce "back towards where it came from", then that's simply a matter of inverting the .velocity vector. (ie: self.velocity = self.velocity * -1).
necros
 
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

Re: Reversing the angles of an entity

Postby DusterdooSmock » Wed Sep 28, 2011 1:33 pm

Alright, thanks guys. :D
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Re: Reversing the angles of an entity

Postby Cobalt » Mon Oct 10, 2011 11:52 pm

Yes, & the darkplaces bouncemissile is suppose to pretty much do this too. After I tested it, it does work but you still need to add in some -velocity_z on your own (in the entitys touch pointer) if its a projectile such as nails....else they bounce forever with a small chance of ever stopping. Another check to see if they are in water, slime or lava too...I decided to make them a movetype_toss if they are now in a liquid....lava burns em up......
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Re: Reversing the angles of an entity

Postby DusterdooSmock » Tue Oct 18, 2011 9:56 pm

Ok, now I would like to expand upon this a little bit...

Image

Lets say the projectile flies at wall "A" from location 1.
How would I alter the angles of the projectile so that after it hits wall "A", it flies towards wall "B", and then when it hits wall "B", it changes its angles again so that it flies towards location 2?
And, vice versa; if the projectile flew at wall "B" from location 2, it would alter its angles so that it flies at wall "A", then when it hits wall "A", it alters its angles again so that it flies towards location 1.
Sort of like a "ricochet" effect...
Last edited by DusterdooSmock on Wed Oct 19, 2011 8:04 pm, edited 2 times in total.
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Re: Reversing the angles of an entity

Postby r00k » Tue Oct 18, 2011 10:22 pm

ent.movetype |= MOVETYPE_BOUNCE ?
r00k
 
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: Reversing the angles of an entity

Postby DusterdooSmock » Tue Oct 18, 2011 10:33 pm

DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Re: Reversing the angles of an entity

Postby Nahuel » Wed Oct 19, 2011 8:32 pm

hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: Reversing the angles of an entity

Postby DusterdooSmock » Thu Oct 20, 2011 12:06 am

I'll give it a shot. Thanks. ;)

EDIT:
It works like what I needed. Thank you. :)
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 3 guests