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

attach_view issue (model is inverted when aiming up/down)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SVC
Junior Member
Join Date: Mar 2021
Old 03-30-2021 , 09:06   attach_view issue (model is inverted when aiming up/down)
Reply With Quote #1

Hello all, i'm new here, but i've been visit this forum from a long time ago.

Either way, i'm written this thread because i'm start having some problems with attach_view native (pfnSetView). In order to explain detail, this is what I've done:

I make a weapon-ent (info_target), then I set this model to a weapon (lets say ak47) and change the player's view to this entity. Theoretically with this way we can make customizable weapons (I mean add glowing, change sking and/or body easily, etc)

The issue comes when i look up with that entity, basically when I do that the weapon that you'are watching will go look to the down-side. In other words, when player's view is normal and you look up, whatever weapon you have will look up too (the same to the down-side); but strangely, this doesn't happen when I changes player's view this custom weapon-ent (even it's like if up/down view is inverted)

I've try many ways of avoid that, but without success. So I came here and hope if anybody knows a way of doing that (or at least have experienced with this issue)

And yes, as you probable are thinking, all this is only for the purpose of making custom-weapons but I don't care if at the final this can be achieved or not. I only made this thread to share this issue and hope anybody can explain better this.

So this is all, I will waiting any response
Thanks for all, and please forgiveme for bad english.

Last edited by SVC; 03-02-2022 at 17:27.
SVC is offline
SVC
Junior Member
Join Date: Mar 2021
Old 03-30-2021 , 17:17   Re: attach_view (maybe an issue)
Reply With Quote #2

Hello again!.

In order to explain much better this issue, I will show the code I'm actually using:

PHP Code:
#include    AMXMODX
#include    ENGINE

new bool:g_bInvertYaw;

public 
plugin_init()
{
    
register_clcmd("__weapon__""__give_weapon__");
    
register_clcmd("invert_angle""invert_angle");
}

public 
invert_angle() g_bInvertYaw = !g_bInvertYaw;

public 
__give_weapon__(const iPlayer)
{
    
// It's only for testing purpose; code can be improved a lot, I know :)...
    
    
new Float:fCoords[3];
    
entity_get_vector(iPlayerEV_VEC_originfCoords);
    
    
fCoords[2] += 35.0;
    
    new 
iWeapon create_entity("info_target");
    {
        
entity_set_origin(iWeaponfCoords);
        
etity_set_model(iWeapon"models/v_ak47.mdl");
        
        
entity_set_string(iWeaponEV_SZ_classname"__custom_weapon__");
        
entity_set_edict(iWeaponEV_ENT_owneriPlayer);
        
entity_set_float(iWeaponEV_FL_nextthink0.001);
        
        
// I think doesn't necessary explain what it does..
        
attach_view(iPlayeriWeapon);
        
        
register_think("__custom_weapon__""__think_custom_weapon__");
    }
}

public 
__think_custom_weapon__(const iEnt)
{
    new 
iOwner entity_get_edict(iEntEV_ENT_owner);
    
    
/*
    Here I set custom-weapon's angles to the player's view-angles
    However even if I reverse they (more precisely the yaw-angle), the up/down view will be reverse "again"
    
    I can't explain better this, so when you test code you will see what i've saying
    */
    
    
static Float:fViewAngles[3];
    
entity_get_vector(iEntEV_VEC_v_anglefViewAngles);
    
    
// What I'm doing here is reverse the up/down angle (for testing) but doesn't not have effect
    
if (g_bInvertYaw)
        
fViewAngles[0] = -fViewAngles[0];
    
    
entity_set_vector(iEntEV_VEC_anglesfViewAngles);
    
entity_set_float(iEntEV_FL_nextthink0.001);

Now, the reason what I'm reverse the yaw-angle on weapon's think is because before testing this way, I was creating this entity and in each frame I put his coords in front on player's view (by hooking pfnAddToFullPack), nothing new really; The thing is if I use the player's v_angles I need to reverse the yaw-angle so that the custom-weapon ent will aim correctly. So i was thinking doing that here will work too, but it seems that not.

I hope you will understand now better this.

Again sorry for my bad english, and sorry if this can be considered "bump"
SVC is offline
SVC
Junior Member
Join Date: Mar 2021
Old 03-02-2022 , 14:52   Re: attach_view (maybe an issue)
Reply With Quote #3

Hello again, after a long time I have come back to ask you for help with this. I recently opened a thread on the official GitHub page but I haven't received any response yet.

I really hope that I can receive any help on this topic, regardless of whether it can be achieved in the end or not.

For those who have not yet understood, I summarize them:
  1. I create a custom entity (I assign its respective model, its origin, etc...).
  2. I link it to the player in question (pev->owner).
  3. I assign the player's view to this new entity (pfnSetView/PF_setview_I).
  4. On each entity think I take the v_angle of the player and assign them to the entity.
  5. If I rotate my camera sideways (right/left), everything works fine, the "gun" is aimed fine.
  6. If I point my camera up -> the player view will also point up (this is fine) BUT -> the entity model will point down (this is wrong).
  7. If I pointed my camera down, the same thing happens as in the previous case but in reverse (player view is pointed down -> model points up).

In conclusion using the code I left above, an issue occurs when you aim down and/or up with the "gun" (it's just a simple model, and the same thing happens regardless of the model; I even tried the chick.mdl and the same thing happened).

Here are some pictures for better understanding:

Default camera position


Pointing up (the model "goes down")


Pointing down (the model "goes up")


I look forward to your responses. I think that if this can be solved it can be a great method to customize weapons, I hope so.

Excuse my bad english, I use the translator.

Last edited by SVC; 03-02-2022 at 14:55.
SVC 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 10:47.


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