Raised This Month: $51 Target: $400
 12% 

[ H3LP ] Origin to angle?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-06-2018 , 21:30   [ H3LP ] Origin to angle?
Reply With Quote #1

Hello, how I can convert one origin vector into a angle vector? I've tried with vector_to_angle but it didn't work.

Code:
public Camera_Think(this) {     static pevOwner, Float:flNextThink, Float:vecAngles[3], Float:vecOrigin[3];     pevOwner = get_entvar(this, var_owner);     flNextThink = get_gametime() + 0.1;     if (is_nullent(pevOwner))     {         set_entvar(this, var_nextthink, flNextThink);         return;     }     get_entvar(pevOwner, var_origin, vecOrigin);     vector_to_angle(vecOrigin, vecAngles);     vecOrigin[2] += 250.0;     set_entvar(this, var_angles, vecAngles);     set_entvar(this, var_v_angle, vecAngles);     entity_set_origin(this, vecOrigin);     //set_entvar(this, var_fixangle, 1);     set_entvar(this, var_nextthink, flNextThink); }
__________________








CrazY. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-06-2018 , 22:37   Re: [ H3LP ] Origin to angle?
Reply With Quote #2

If you replace "origin" with "direction", that is literally the definition of of vector_to_angle() so why would you think it's not working? Also, it's been around for a long time, I'm sure if it wasn't working, it'd be reported by now.

It sounds like something else that you are doing is actually wrong. If you want to claim vector_to_angle() is broken, you'd have to test only that function and nothing else.
__________________

Last edited by fysiks; 09-07-2018 at 23:00.
fysiks is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-07-2018 , 06:55   Re: [ H3LP ] Origin to angle?
Reply With Quote #3

Do debugging.

What actually are you trying to do? (Where do you want to put the camera)
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 09-07-2018 at 07:20.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-07-2018 , 08:06   Re: [ H3LP ] Origin to angle?
Reply With Quote #4

I might be wrong here and I cant look stuff up right now.
An origin is a position, it contains no angles.
A vector is a normalized(?) angle, ranging from -1.0 to 1.0, used for adding a distance in a certain direction by multiplication, like get_user_aim(). Not sure about other uses, not great at trigonometry.

I’m guessing that you want to calculate the angle from one origin to another and adding a height (which you must do before calculating the angle). I don’t know how to do that but I’m sure someone do. Does your camera just change angle from a fixed point or do you want it to follow like any third person camera would?
__________________

Last edited by Black Rose; 09-07-2018 at 08:10.
Black Rose is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-07-2018 , 09:17   Re: [ H3LP ] Origin to angle?
Reply With Quote #5

Basically what I'm trying to achieve is what @Black Rose said, calculate a angle from camera origin to owner origin and set camera origin above of the owner, and yes, the camera will follow owner as an 3rd person.

How it must look:


How it's looking right now:


That's why I suppose it's not working, Not sure if I forgot anything or I'm just doing it wrong way.
__________________









Last edited by CrazY.; 09-07-2018 at 09:19.
CrazY. is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-07-2018 , 09:38   Re: [ H3LP ] Origin to angle?
Reply With Quote #6

Origin to Angle? wut, how this gonna work
Here's camera plugin: https://forums.alliedmods.net/showthread.php?t=280234
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM

Last edited by Ghosted; 09-07-2018 at 09:42.
Ghosted is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-07-2018 , 09:55   Re: [ H3LP ] Origin to angle?
Reply With Quote #7

If the camera should be looking in the same direction the player is looking, just set its angle to be the same as player's.
To position it such that it's always behind the player, convert player's view angle into a vector and mulitply it by distance * -1.
__________________
klippy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-07-2018 , 10:06   Re: [ H3LP ] Origin to angle?
Reply With Quote #8

I have some questions are you trying to attach the camera 3rd person to the player or the entity (tank)

If its the tank does pevOwner = to the tank entity?
PHP Code:

public Camera_Think(this)
{
    static 
pevOwnerFloat:flNextThinkFloat:vecAngles[3], Float:vecOrigin[3];

    
pevOwner get_entvar(thisvar_owner);
    
flNextThink get_gametime() + 0.1;

    if (
is_nullent(pevOwner))
    {
        
set_entvar(thisvar_nextthinkflNextThink);
        return;
    }

    static 
Float:fVector[3], Float:fPlayerVAngles[3];
    
get_entvar(pevOwnervar_originvecOrigin);
    
get_entvar(get_entvar(pevOwnervar_owner), var_v_anglefPlayerVAngles);
    
angle_vector(fPlayerVAnglesANGLEVECTOR_FORWARDfVector);
    
fVector[0] = vecOrigin[0] + (fVector[0] * -50.0);
    
fVector[1] = vecOrigin[1] + (fVector[1] * -50.0);
    
fVector[2] = vecOrigin[2] + 250.0;
    
vecAngles[0] = fPlayerVAngles[0];
    
vecAngles[1] = fPlayerVAngles[1] * (fPlayerVAngles[1] > 0.0) ? -1:1;

    
entity_set_origin(thisfVector);
    
set_entvar(thisvar_anglesvecAngles);
    
set_entvar(thisvar_fixangle1);

    
set_entvar(thisvar_nextthinkflNextThink);

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 09-07-2018 at 10:48.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-07-2018 , 10:25   Re: [ H3LP ] Origin to angle?
Reply With Quote #9

I'm trying to attach the camera to the tank, not player. Camera owner is tank, and tank owner is player. I'm not trying to achieve 3rd view, it looks more with "upside view/top-down", like what whe see in 2d games.


__________________









Last edited by CrazY.; 09-07-2018 at 10:30.
CrazY. is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-07-2018 , 10:37   Re: [ H3LP ] Origin to angle?
Reply With Quote #10

So it should always look down but rotate the same way the tank rotates?
__________________
klippy 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 09:23.


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