Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Odd little vector predicament
Odd little vector predicament
2002-12-31, 8:06 PM #1
I'm currently using:
Code:
                  look_vector=vectorsub(getthingpos(victim), getthingpos(player));
                  setthinglook(player, look_vector);

This on a rapid pulse creates an aimbot effect.

What I want to figure out how to do is set the player to look halfway between where he's looking and where the victim is.

Example:
The player is looking forward.
The victim is 90 degrees off to the side.
When the first pulse is triggered, he looks 45 degrees to the side, halfway between his current lookpos and the victim's position.
When the second pulse is triggered, he looks 22.5 degrees further in that direction, exactly half-way between his current lookpos and a lookpos that would make him look straight at the victim.

How could I acheive something like this?
2002-12-31, 8:08 PM #2
Thats alot of weird vector math that Id rather not think about right now. Im sure Hellcat would be better at that...
And when the moment is right, I'm gonna fly a kite.
2002-12-31, 8:09 PM #3
I'll be darned if LEC didn't screw us over by making everyone's vectors relative to the level.
2002-12-31, 8:49 PM #4
*deep breath*

Code:
   add_vector = VectorSub(VectorSub(GetThingPos(victim), GetThingPos(Player)), GetThingLVec(player));
   SetThingLook(player, add_vector);


Give that a try. It might work, but that's the best I can do this late at night. Also try this.
Code:
   add_vector = VectorSub(VectorSub(GetThingPos(victim), GetThingPos(Player)), GetThingLVec(player));
   add_vector = VectorAdd(add_vector, GetThingLVec(player));
   SetThingLook(player, add_vector);


I'll see if I can think of anything else by tomarrow.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-12-31, 9:07 PM #5
Errr dp did you test your code? Cause the z on the player doesnt quite work.

I quickly wrote a short piece of code which is working. I just used the bryar cog to test it, works well but its abit fast to rotate. Play around with the 0.5 in the vector scale if you like.

Code:
pulse:
	//Where the player needs to end up looking
	final_vector = VectorSet(1, 0, 0);

	//Get the current look of the player by firing a ghost. Thats our current look
	current_look=FireProjectile(player, lookghost, -1, -1, length, '0.0 0.0 0.0', 1.0, 0x20, 30, 10);
	start_vector = GetThingLVec(current_look);

	//Now subtract the start vector from the final vector and scale by 0.5. Add it to our current look
	start_vector = VectorAdd(start_vector, VectorScale(VectorSub(final_vector, start_vector), 0.5));

	//Set the players look to the new position
	SetThingLook(player, start_vector);  

end


If you want I can post the whole bryar cog.

[This message has been edited by Hellcat (edited January 01, 2003).]
Team Battle.
2002-12-31, 10:20 PM #6
I just noticed the SetThingLook for the VectorZ is abit weird... I dunno how to fix it. The code works great for scrolling though.

[edit]The Z axis is totally wasted [http://forums.massassi.net/html/frown.gif] , does anyone know how to control it? [/edit]

[This message has been edited by Hellcat (edited January 01, 2003).]
Team Battle.
2003-01-01, 10:34 AM #7
As far as I know, the headpitch cannot be controlled in JK. The Z component of the vector used in SetThingLook changes the pitch of the player's torso, unless he's standing on a surface (in this case the Z component of the player's lookvec will remain unchanged).

-RayNbow
-RayNbow

↑ Up to the top!