Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UFPS : Ultimate FPS [ RELEASED ]

Discussion in 'Assets and Asset Store' started by VisionPunk, Mar 9, 2012.

Thread Status:
Not open for further replies.
  1. Andy2222

    Andy2222

    Joined:
    Nov 4, 2009
    Posts:
    81
    Btw why are so many people using the none generic version like this:

    Code (csharp):
    1.   Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));
    If the assigning variable is of the same type u looking for, using the generic version is shorter and better readable.

    Code (csharp):
    1.   Player = transform.root.GetComponentInChildren<vp_FPPlayerEventHandler>();

    bye Andy
     
  2. theSoenke

    theSoenke

    Joined:
    Dec 4, 2012
    Posts:
    106
    I have to edit the zoom state in the Vp_FPWeapon script on the weapon right? Here is the current file.

    PositionOffset 0 -0.2232973 0.15
    RotationOffset -2.611479 0 0
    RotationSpringStiffness 0.025
    RotationSpringDamping 0.35
    ShakeSpeed 0.8
    ShakeAmplitude 0.25 0 0.5
    BobAmplitude -0.4 -1.5 -0.75 -0.01
    BobRate 1 -0.5 0.5 0.5
    BobInputVelocityScale 8
    BobMaxInputVelocity 50
    RenderingFieldOfView 20
    RenderingZoomDamping 0.1
    PositionSpringStiffness 0.045
    PositionSpringDamping 0.45
    PositionWalkSlide 0.2 0.5 0.2

    Can give me somebody a tip what i should edit to achieve a zoom effect? I already tried a few things, but nothing worked
     
  3. Andy2222

    Andy2222

    Joined:
    Nov 4, 2009
    Posts:
    81
    RenderingFieldOfView and RenderingZoomDamping are the parameters u are looking for. Make sure u edit the correct file like "WeaponPistolZoom" that is also set for the zoom state. U could also use the PositionOffset for the vp_FPCamera, to move the camera ahead, but i guess this would have some sideeffects.
     
  4. theSoenke

    theSoenke

    Joined:
    Dec 4, 2012
    Posts:
    106
    RenderingFieldOfView just stretches the weapon and when i edit RenderingZoomDamping i see no real difference to before
     
    Last edited: Jul 30, 2013
  5. Andy2222

    Andy2222

    Joined:
    Nov 4, 2009
    Posts:
    81
    My fault its the "RenderingFieldOfView" in the CameraZoom.txt for the vp_FPCamera component.
     
  6. theSoenke

    theSoenke

    Joined:
    Dec 4, 2012
    Posts:
    106
    Thanks, but is there a way to set the zoom for every single weapon?
     
  7. Andy2222

    Andy2222

    Joined:
    Nov 4, 2009
    Posts:
    81
    That seems only possible by scripting.
    U need to derive your own vp_FPWeapon and add a extra per weapon FoV field, than override the OnStart_Zoom() inside vp_FPCamera, to get the current weapon and set this value to the current cameras RenderingFieldOfView.

    I'm not fully sure of the order for the state presets, but i assume they are applied before OnStart_Zoom() is called.

    If i understand the Activity system correctly, u can also add a additional OnStart_Zoom() to your own vp_FPWeapon component and get the vp_FPCamera component and set the RenderingFieldOfView. This should actually be better, since it restricts the special zoom behavior to your own special weapon.
     
  8. BrandSpankingNew

    BrandSpankingNew

    Joined:
    Nov 20, 2012
    Posts:
    220
    Building upon the example. You now need to make presets that satisfy your requirements. Here, we use existing ones for ease of use:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class ScriptOnAWeapon : MonoBehaviour {
    6.  
    7.     public vp_FPPlayerEventHandler Player = null;  
    8.     public vp_FPCamera m_FPCamera = null;
    9.     public TextAsset SniperCamera = null;
    10.     public TextAsset CameraDefault = null;
    11.    
    12.    
    13.     protected virtual void Awake()
    14.     {
    15.  
    16.         Player = (vp_FPPlayerEventHandler)transform.root.GetComponentInChildren(typeof(vp_FPPlayerEventHandler));
    17.         m_FPCamera = (vp_FPCamera)transform.root.GetComponentInChildren(typeof(vp_FPCamera));
    18.     }
    19.  
    20.     protected virtual void OnEnable()
    21.     {
    22.         if (Player != null)
    23.             Player.Register(this);
    24.     }
    25.  
    26.     protected virtual void OnDisable()
    27.     {
    28.         if (Player != null)
    29.             Player.Unregister(this);
    30.     }
    31.  
    32.     protected virtual void OnStart_Zoom()
    33.  
    34.     {
    35.         m_FPCamera.Load(SniperCamera);
    36.     }
    37.  
    38.    
    39.     protected virtual void OnStop_Zoom()
    40.     {
    41.         m_FPCamera.Load(CameraDefault);
    42.     }
    43.    
    44. }
    45.  
     
  9. theSoenke

    theSoenke

    Joined:
    Dec 4, 2012
    Posts:
    106
    Thank you so much! But when one problem is solved another occurs ;) I have now the problem that the sniper is not very accurate. I set the spread to 0, but the bullet is still not very accurate. Do i have to change more than just the spread of the projectile in the Vp_FPWeaponShooter script?
     
  10. CoffeeOD

    CoffeeOD

    Joined:
    Jun 24, 2013
    Posts:
    15
    Question for those who have managed to add new weapons into UFPS, what progman did you use animate/add weapons into arms? I have tried to use blender but I cant seem to import .fbx files to it (UltimateFPS\Content\Art\Weapons\Source\BasicArms), might be simple noob-not-understanding-how-things-work error in my part.
     
    Last edited: Jul 30, 2013
  11. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hey guys, just want to let you know that we are having a hard time keeping up with support at the moment due to a big surge of interest in UFPS. Good news is we're currently at work setting up a new forum which should solve some of the gridlocks in this thread. Also, it'll make it easier to collaborate on solutions and generally make it easier to get answers. Talk to you soon...

    /Cal
     
  12. BrandSpankingNew

    BrandSpankingNew

    Joined:
    Nov 20, 2012
    Posts:
    220
    I really do not know. That is bizarre, for sure. Someone will have an idea. Be patient. ....
     
  13. BrandSpankingNew

    BrandSpankingNew

    Joined:
    Nov 20, 2012
    Posts:
    220
    Cool news! Been missing you. Hope all goes well. Relax, we will limp until you have time to sort us out.
     
  14. BrandSpankingNew

    BrandSpankingNew

    Joined:
    Nov 20, 2012
    Posts:
    220
    Autodesk offers a free FBX converter. Blender is able to import the converted FBX files (as OBJ files). I believe that the conversion process strips away all animations, but you do end up with the model being imported. There may be a Blender branch available that will directly import FBX, but that would seem to be illegal since Autodesk holds the FBX format very dear.
     
  15. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    This is an error in the documentation. It should be vp_FPPlayerEventHandler.cs. Sorry for the confusion.
     
    Last edited: Jul 31, 2013
  16. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    Hi Zozo,

    What kind of implementation are you looking for. Do you just want a flashlight to follow the camera with bobbing and all or are you looking to have a separate hand that will hold the flashlight? Once you provide more information I may be able to help.

    Just for your information, dual weapons is planned in an upcoming release so this may be what you are looking for, to swap one of the weapons for a flashlight. Currently, you could setup a flashlight just like how the weapons are setup, but then you wouldn't be able to attack unless your flashlight shot, hehe. Another option may be to add a light source as a child to the camera and then it would inherit the camera's bobbing and such, you wouldn't have a hand holding this though without doing some extra coding yourself.
     
    Last edited: Jul 31, 2013
  17. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    Great suggestion. Thanks for helping out :)
     
    Last edited: Jul 31, 2013
  18. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    Hi Wrekk,

    The function you are looking for OnAttempt_DepleteAmmo is in vp_SimpleInventory :)
     
    Last edited: Jul 31, 2013
  19. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    Hi LoonyBen,

    Are you trying to make your enemies cause damage to the player when they punch? If so, take a look at the vp_SimpleAITurret and see how it uses the vp_Shooter to accomplish this. Also, the upcoming AI release has ways for damage to be applies via a melee attack, so you may like this when it's released soon.

    As for the capsule collider, checkout vp_HitscanBullet. This has a "No Decal On These Layers" property that you can add the layer of the capsule collider to in order to prevent adding the bullet holes.
     
    Last edited: Jul 31, 2013
  20. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    Android support is planned to be released with the mobile version or shortly thereafter. The mobile release is planned for sometime this summer.
     
    Last edited: Jul 31, 2013
  21. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    You are correct, this was a bad decision on my part and will be changed in the next update.
     
  22. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    Hi Andy,

    This is a great suggestion and I'll look into allowing the dev to specify the type for this sort of thing. Thanks for the suggestion :)
     
  23. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    Hi Infernomaster,

    This seems odd to me that it would suddenly start doing this. Perhaps there was some code that was changed that caused this behavior or maybe the console is showing some errors that is preventing this to function properly. If you could provide a little more information as to any changes you made or anything else, I'd be happy to assist you in figuring this out.
     
  24. VirtualJunky

    VirtualJunky

    Joined:
    Jul 20, 2013
    Posts:
    7
    Edit: Figured it out.
     
    Last edited: Aug 1, 2013
  25. Glazer

    Glazer

    Joined:
    Jul 18, 2013
    Posts:
    4
    EDIT: Never mind, answered my own question.
     
    Last edited: Aug 1, 2013
  26. TheStone

    TheStone

    Joined:
    May 18, 2013
    Posts:
    77
    Hi vision punk, can you elaborate a little bit more on how to inflict damage on the player using hands attack.

    1.- you look for the player using a raycast, when you find it you return a transform..
    2.- if target is not null, then you attack it.
    3.- m_Shooter.TryFire();
    4.- Then TryFire calls -> Fire()
    5.- Then SpawnProjectiles();

    And this is where I get lost :confused: how you cause damage to the player, with an enemy using his hands... Can you help me understand.

    Thanks!
     
  27. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    The projectile that is spawned should have a vp_HitscanBullet on it. The hitscan component needs to have the ignore local player unchecked. The vp_HitscanBullet will then send a Damage message to whatever it hits using SendMessageUpwards() when it is spawned. Hope this helps :)
     
  28. AgingPunk

    AgingPunk

    Joined:
    Jul 25, 2013
    Posts:
    10
    Hello, I'm a beginner to unity and ufps camera. I am having fun learning to use everything and am getting better. Here is a question I have right now. I have an enemy who is animated, he follows my player and attacks. Using the vp_damagehandler it works fine that I am able to shoot him and destroy him. I am wondering however how to properly transition him to a ragdoll on death. If I just make a ragdoll prefab and put it on the death effect gameobject the character pops into the T pose before turning into the ragdoll and falling to the ground. I found a c# script in the unity 4.x cookbook for activating/deactiving a ragdoll on a character but I have no idea how to properly add that code to vp_damagehandler if that's what needs to be done. Help would be greatly appreciated, thanks.
     
  29. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,910
    Does the latest NGUI work with this? I can't get it to work. I have to set the camera to Solid then Depth in the inspector for it to work, but that doesn't work with code.

    SOLUTION: Changing the Depth value to 2 or more fixes it.
     
    Last edited: Aug 2, 2013
  30. BrandSpankingNew

    BrandSpankingNew

    Joined:
    Nov 20, 2012
    Posts:
    220
    I was thinking that maybe you could check some of the UFPS videos, where that ragdoll effect is used, and ask one of those authors directly? They may not see this forum, but they might take a minute to answer a direct request. It's probably pretty easy once one knows how.

    EDIT: I just came across this short forum thread where someone solved that "T-pose" problem. http://forum.unity3d.com/threads/80903-Noticeable-T-Pose-when-using-a-ragdoll and here is another bit of the answer ... http://answers.unity3d.com/questions/213139/ragdoll-pauses-for-a-second-when-instantiating.html
     
    Last edited: Aug 2, 2013
  31. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    182
    Hey! How can i disable mousle look? C#
     
  32. AgingPunk

    AgingPunk

    Joined:
    Jul 25, 2013
    Posts:
    10
    @BrandSpankingNew thanks a lot for sharing those links, I will look into them later today. Much appreciated.
     
  33. TheStone

    TheStone

    Joined:
    May 18, 2013
    Posts:
    77
    VisionPunk, thanks for your fast replay, but there is not projectile in the hand fight, let suppose it is a tiger in the jungle, hitting you, how do you go about inflicting damage to the player?? :confused:

    Thanks.
     
  34. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    Hi TheStone,
    In this case, using a vp_Shooter with a projectile that has a vp_HitscanBullet on it is still a valid option. You can set the distance to be short like a melee attack would be also.
     
  35. BrandSpankingNew

    BrandSpankingNew

    Joined:
    Nov 20, 2012
    Posts:
    220
    Just installed the free 4.2 version of Unity. There be SHADOWS here! Woot! What fun! Maybe in another 6 months I will feel competent enough to "need" the Pro version.
     
  36. BrandSpankingNew

    BrandSpankingNew

    Joined:
    Nov 20, 2012
    Posts:
    220
    Wow, that is clever. Thanks for thinking about that. That will save some work and stumbling.
     
  37. phato777

    phato777

    Joined:
    Dec 14, 2012
    Posts:
    138
    Ya, it works quite well actually. If you put the vp_Shooter on an empty game object and then child it to the weapon and position it where the impact would possibly take place (middle of a sword, tip of a tiger claw, etc...) and then when the attack animation is played, get the length of that animation and cut it in half to get a delay for triggering the TryFire method, it works pretty great.

    Something like this pseudo code should help.
    Code (csharp):
    1.  
    2. float delay = (animation.length * animation.speed) * .5f;
    3. vp_Timer.In(delay, delegate{
    4.     shooter.TryFire();
    5. });
    6.  
     
  38. Wrekk

    Wrekk

    Joined:
    Jul 16, 2012
    Posts:
    51
    Create a script, add it to the tiger, use SendMessage to call the damage method on the player.
    You can do it without SendMessage, you could just call the method directly.
     
  39. TheStone

    TheStone

    Joined:
    May 18, 2013
    Posts:
    77
    Thanks!!! visionPuck, I am trying to keep up, I am new to Unity, many years developer, but new to unity, let me see if I can make it work..
     
  40. TheStone

    TheStone

    Joined:
    May 18, 2013
    Posts:
    77
    Hey Wrekk,

    Thanks for stepping in!! I was trying something like that but without any success... on the player I have all the scripts that come with the SFPS, and then I added a different script with this...

    protected void OnCollisionEnter(Collision collision)
    {

    Damage(1);

    }

    If I have soldiers shooting at me, I got it working not problem, because the shoot a projectile and I did what VisionPunk told me, in the projectile there is a slot for placing the mane of the method you need to call in the Player to be able to inflict damage, but for the live of me I cant visualised in code what he is telling me...

    because in what moment should I instanciate a projectile on a tiger, with no weapon... and where ???

    This is why I was trying On collisionEnter....

    Thanks for you help!!
     
  41. Wrekk

    Wrekk

    Joined:
    Jul 16, 2012
    Posts:
    51
    TheStone, you should do something like this (in my opinion, there may be better ways).

    public class YOURSCRIPTNAMEHERE {
    private GameObject player;
    public string DamageMethodName;
    public float Damage;

    void Start() {
    player = GameObject.FindGameObjectWithTag("Player"); //Your player needs to have this tag
    }

    void Update() {
    player .SendMessageUpwards(DamageMethodName, Damage, SendMessageOptions.DontRequireReceiver); //You shouldn't put this in the update method, as it'll damage the player every frame. Instead, you should probably make an attack method with timers etc, though I won't go into details.
    }
    }
     
  42. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    182
    thanks for the answer :/
     
  43. Wrekk

    Wrekk

    Joined:
    Jul 16, 2012
    Posts:
    51
    Mouse look? Hmm, I'm sorry but I don't really know, as I haven't had the need for that yet.
    Though I guess you'd have to go into vp_FPInput.cs and comment out the mouse input.

    EDIT: Changed "vp_Input" to "vp_FPInput"
     
    Last edited: Aug 2, 2013
  44. TheStone

    TheStone

    Joined:
    May 18, 2013
    Posts:
    77
    Thanks Wrekk! thanks for the piece of code, it will help me!!!!

    But the problem I am having is to when to call the send message method? like you said, we cant call it in the update... It needs to be called when the tiger hits the player, I was assuming that the tiger when it gets close to the player the collisionEnter method gets called, but is not like this, or I am doing something wrong...

    I dont know if I explaining well, as english is my second language...

    Where should I call it? you are saying to create a new script and add it to the player, but when the tiger hits the player, how the player knows that is being hit, so I can call sendMessage from there.??

    THanks! a lot!
     
  45. Wrekk

    Wrekk

    Joined:
    Jul 16, 2012
    Posts:
    51
    When your tiger is moving, you could check the distance between the player and the tiger. And if it's below a certain number (like 2), it should attack if its attack timer is 0. I could come up with a code example like before if you want.

    EDIT: I wouldn't use OnCollisionEnter for this, as it's only called when the objects collide. The distance check is much more reliable in my opinion.
     
    Last edited: Aug 2, 2013
  46. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    182
    thanks wreek! at least you tried :) but developer need to answer this. Im sure that mouse look script is in the vp_FPSCamera but i dont know how to freeze it or disable it. I can do it in normal character controller.
     
  47. TheStone

    TheStone

    Joined:
    May 18, 2013
    Posts:
    77
    Please if you are so kind, I dont have much experience on unity, I will really appreciate it!!!

    TheStone.
     
  48. Wrekk

    Wrekk

    Joined:
    Jul 16, 2012
    Posts:
    51
    public class YOURSCRIPTNAMEHERE {
    private GameObject player;
    public string DamageMethodName;
    public float Damage;
    vp_Timer.Handle m_Timer = new vp_Timer.Handle(); //timer
    private bool isAttacking; //bool to check if it's already attacking
    public float dist; //minimum distance til you start attacking
    public float attackSpeed; //attack speed obviously

    void Start() {
    player = GameObject.FindGameObjectWithTag("Player");
    isAttacking = false;
    }

    void Update() {
    if (CheckDistance()) {
    Attack();
    }
    }

    void Attack() {
    if (!isAttacking) {
    player .SendMessageUpwards(DamageMethodName, Damage, SendMessageOptions.DontRequireReceiver);
    isAttacking = true;
    vp_Timer.In(attackSpeed,delegate() {
    isAttacking = false;
    },m_Timer);//timer to reset isAttacking

    }
    }

    bool CheckDistance() {
    if(Vector3.Distance(transform.position,player.transform.position) <= dist) {
    return true;
    }
    else {
    return false;
    }
    }
    }

    I haven't tested this, so it might not work.

    I'll have a look at it tomorrow. :)
     
    Last edited: Aug 2, 2013
  49. TheStone

    TheStone

    Joined:
    May 18, 2013
    Posts:
    77
    Shoot! thanks!! is no problem if you havent test it... I can debug it ofr twick the code, I just needed an idea where to start. Thank you very much Amigo!
     
  50. Wrekk

    Wrekk

    Joined:
    Jul 16, 2012
    Posts:
    51
    No problem, I'm happy to help.
     
Thread Status:
Not open for further replies.