Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

fpsarmedunity

Premium Member
  • Content Count

    181
  • Joined

  • Last visited

  • Days Won

    2

fpsarmedunity last won the day on October 25 2016

fpsarmedunity had the most liked content!

Community Reputation

17 Good

About fpsarmedunity

  • Rank
    Member
  • Birthday 11/20/1950

Profile Information

  • Gender
    Male
  • Location:
    World

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. thanks mate you are a life saver... many thanks hope this could help someone else...thanks again..
  2. Hi to all.. i used the great peek.jc script on my project an all worked fine until i upgraded to unity 2018.3 where js is deprecated so i would to aks if someone could try to convert it in c# herethe script..i tried but without good results. var cam : Transform; var cam2 : Transform; private var nextPos : float; private var nextPos2 : float; private var dampVelocity : float; private var dampVelocity2 : float; function Update () { var newPos = Mathf.SmoothDamp(cam.transform.localPosition.x, nextPos, dampVelocity, 0.2); var newPos2 = Mathf.SmoothDamp(cam.transform.localPosition.y, nextPos2, dampVelocity2, 0.2); cam.transform.localPosition.x = newPos; cam.transform.localPosition.y = newPos2; var newPos3 = Mathf.SmoothDamp(cam2.transform.localPosition.x, nextPos, dampVelocity, 0.2); var newPos4 = Mathf.SmoothDamp(cam2.transform.localPosition.y, nextPos2, dampVelocity2, 0.2); cam2.transform.localPosition.x = newPos; cam2.transform.localPosition.y = newPos2; if(Input.GetKey("x")){ nextPos = 0.7; nextPos2 = 0.0; }else if(Input.GetKey("z")){ nextPos = -0.7; nextPos2 = 0.0; }else if(Input.GetKey("c")){ nextPos = 0.0; nextPos2 = 0.0; // FIXED BUG ON "c" PRESS PREVOIUS VALUE "-1.0" JCLEON }else{ nextPos = 0.0; nextPos2 = 0.0; } } any help ti would be very appreciated ..thanks inadvance
  3. Hi i know this is a very old topic lol but i was using this script in my project and it worked great.. btw now i upgraded t ounty 2018.3 andmaybe since jc is deprecated script doesnt work anymore.. so please could someone try to coventer it to c# i tried but i'm not so able to make that...
  4. nevermind ..solved by myself i simply changed this line if(Physics.Raycast(transform.position, transform.forward, out hits, 1.5f, layerMask.value)) into this if(Physics.Raycast(transform.position, transform.forward, out hits, 0f, layerMask.value)) this solved some really annoying bugs on items distance pickups since beforewhen player tried to pickup really near objets since the "hlding distance " was too big several times picked objects fall under floor when player tried to pickup them.. now this bug is gone.. ..I'm really happy... thanks to all
  5. hi mate and thanks for your reply too but i cannot undrestood whha you mean.. can you elaborate please?? thanks in advance
  6. hi and thanks i tried with: Physics.IgnoreLayerCollision(9, 15); // there are the affectd layers "Player" and "Pickup" and with Physics.IgnoreCollision(obj.GetComponent<Collider>(), GetComponent<Collider>()); where "obj" is the generic carried Gameobject but i dont know if i done correcly btw thisis my complete GrabObjects scritp if could help using System.Collections; using System.Collections.Generic; using UnityEngine; using EasySurvivalScripts; public class GrabObjects : MonoBehaviour { //FPS KIT [www.armedunity.com] public float grabPower = 10.0f; public float throwPower = 25.0f; public float RayDistance = 3.0f; public LayerMask layerMask; private bool grab, drop = false; public Transform pos; public float adjust; Rigidbody obj; // UI Integration Start public GameObject InteractUIPickupExamine;//ADDON JC LEON public GameObject InteractUIExamine;//ADDON JC LEON public GameObject InteractUIPickupExamineCollectable;//ADDON JC LEON public GameObject InteractUIExamineCollectable;//ADDON JC LEON public GameObject InteractUIPickupThrowRotate;//ADDON JC LEON public GameObject InteractUIPickup;//ADDON JC LEON ONLU PICKUP public GameObject StaticCross;//ADDON JC LEON ONLU PICKUP // UI Integration End //ADDon JC LEON [Header("JC LEON Weight Integration")] [Tooltip("Set the max mass for rigidbodies to be picked up")] public float maxMass = 10; private float mass, curthrowPower; [Header("JC LEON Object Rotation Integration")] public float rotateSpeed; public KeyCode rotateL; public KeyCode rotateR; // public bool setObjectRotation; public bool isGrabbing; //public float followSpeed; //public float forceToDrop; public float distanceToDrop; [Header("JC LEON other scripts References Integration")] public WeaponManager weaponManager; public ObjectExamineManager objectExamineManager; public float GrabTime; public bool _canPickup;//ADDON JC LEON ONLY PICKUP OBJECt //Addon JC LEON void Update () { CheckObjectForPickupOnly();//ADDON JC LEON ONLY PICKUP if (Input.GetKeyDown(KeyCode.Mouse1)) { RaycastHit hit; if(Physics.Raycast(transform.position, transform.forward, out hit, RayDistance, layerMask.value)) { Pickable pickable = hit.collider.GetComponent<Pickable>(); //if(pickable) if (/*pickable &&*/ hit.rigidbody && !hit.rigidbody.isKinematic && hit.rigidbody.mass <= maxMass && WeaponManager.instance.WeaponCurrentlySelected() == false) { if (Inventory.instance.currentlyHeldItem != null){ Inventory.instance.UnHoldItem(); Inventory.instance.UnHighlightSelectedSlot(Inventory.instance.SelectedSlot); Inventory.instance.UnSelectSlot(); Inventory.instance.HideActionButtons(); } //ADDON JCLEON mass = hit.rigidbody.mass; if (mass < 2) mass = 2; // сила броска, зависит от массы, поэтому проверяем, чтобы минимальная масса не была равна или меньше единицы curthrowPower = throwPower / mass; //ADDON JCLEON grab = true; obj = hit.rigidbody; obj.isKinematic = true; obj.GetComponent<Collider>().enabled = false; obj.transform.parent = pos; } else { if (/*pickable*/ hit.rigidbody && !hit.rigidbody.isKinematic && hit.rigidbody.mass > maxMass) // Addon JCLEON { Debug.Log("Hey"); pickable.ShowMessage(); } } } } //ADDON JCLEON START if (isGrabbing) { if (Input.GetKey(rotateL)) { obj.transform.Rotate(new Vector3(0, rotateSpeed * Time.deltaTime, 0)); } if (Input.GetKey(rotateR)) { /* obj.transform.Rotate(new Vector3(0, -(rotateSpeed * Time.deltaTime), 0));*/ obj.transform.Rotate(new Vector3(rotateSpeed * Time.deltaTime, 0, 0)); } } //ADDON JCLEON END if (isGrabbing) { GrabTime = Time.time; Debug.Log("time"); } if (!isGrabbing) { GrabTime = 0.0f; } if (Input.GetKeyUp(KeyCode.Mouse1)) { if(grab) { StartCoroutine(PrepareToDrop(0f)); } } if (Input.GetKeyDown(KeyCode.Mouse0)) { if(grab) { StartCoroutine(PrepareToDrop(curthrowPower));//ADDON JCLEON } } if(grab) { obj.transform.position =Vector3.Lerp(obj.transform.position, pos.position + (pos.transform.forward * adjust) /*- (pos.transform.up * 0.4f)*/, Time.deltaTime * 3f /*grabPower*/); //obj.transform.rotation = Quaternion.Lerp(obj.transform.rotation, pos.rotation, Time.deltaTime * 5f); obj.GetComponent<Collider>().enabled = true; // ADDON JCLEON ENABLE OBJECT COLLISION WHEN OBJECT IS GRABBED BY THE PLAYER InteractUIPickupExamine.SetActive(false);//ADDON JC LEON UI InteractUIExamine.SetActive(false);//ADDON JC LEON UI InteractUIPickupExamineCollectable.SetActive(false);//ADDON JC LEON UI InteractUIExamineCollectable.SetActive(false);//ADDON JC LEON UI InteractUIPickupThrowRotate.SetActive(true);//ADDON JC LEON UI isGrabbing = true;//ADDON JCLEON weaponManager.enabled = false;//ADDON JCLEON objectExamineManager.enabled = false;//ADDON JCLEON obj.isKinematic = false;//ADDON JCLEON obj.GetComponent<Rigidbody>().useGravity = false;//ADDON JCLEON obj.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;//ADDON JCLEON obj.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;//ADDON JCLEON InteractUIPickup.SetActive(false);//ADDON JC LEON ONLU PICKUP //Physics.IgnoreLayerCollision(9, 15); //Physics.IgnoreCollision(obj.GetComponent<Collider>(), GetComponent<Collider>()); } } IEnumerator PrepareToDrop(float power) { RaycastHit hits; while(!drop) { if(Physics.Raycast(transform.position, transform.forward, out hits, 1.5f, layerMask.value)) drop = false; else drop = true; yield return null; } obj.transform.parent = null; obj.isKinematic = false; obj.GetComponent<Collider>().enabled = true; obj.velocity = transform.forward * power; drop = grab = false; InteractUIPickupThrowRotate.SetActive(false);//ADDON JC LEON UI isGrabbing = false;//ADDON JCLEON weaponManager.enabled = true;//ADDON JCLEON objectExamineManager.enabled = true;//ADDON JCLEON obj.GetComponent<Rigidbody>().useGravity = true;//ADDON JCLEON obj.constraints = RigidbodyConstraints.None;//ADDON JCLEON } //ADDON JC LEON START public void Drop() { StartCoroutine(PrepareToDrop(0f)); } //ADDON JC LEON END // ADDON JC LEON ONLY PICKUP START public void CheckObjectForPickupOnly() { if (!weaponManager.disarmed) { _canPickup = false; InteractUIPickup.SetActive(false); StaticCross.SetActive(false); return; } RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, RayDistance, layerMask.value)) { Pickable pickable = hit.collider.GetComponent<Pickable>(); if (hit.rigidbody && !hit.rigidbody.isKinematic /*&& hit.rigidbody.mass <= maxMass*/ && pickable.isPickableOnly) { InteractUIPickup.SetActive(true); _canPickup = true; StaticCross.SetActive(true); } else { _canPickup = false; InteractUIPickup.SetActive(false); StaticCross.SetActive(false); } } else if (_canPickup == true) { _canPickup = false; InteractUIPickup.SetActive(false); StaticCross.SetActive(false); } } // ADDON JCLEON OLY PIVKUP END } with no results
  7. Hi ,yes i know i made a similar threah some time ago and I have my pickup and grab script fully functional an working but sincerly i'm not completely satisfied with it...since i have a little issue.. my grab script is based on standard fpskit 1.6 GrabObjects script but heavily modified.. the issue is related to the fact i need to left the box collider active even when object is picked up to prefent it clipping with other object but when i left that active and try to set the adjust position to a value lower than 2.5 the grabbed obejct reamins stucked on player after picked up and player cannot leave it.. i was thinking this could be related to the physics interaction layer but tired to disable the interaction between the two interested layer ( pickup and playr) but issues remains.. i was thinking this could be caused from my modified scirpt so i tried with original GrabObjects script but when i left atvie the collider on obejct picjed up and lower the adjust position issue is there.. here the original fpskit 1.5 Grabobjects script using System.Collections; using System.Collections.Generic; using UnityEngine; public class GrabObjects : MonoBehaviour { //FPS KIT [www.armedunity.com] public float grabPower = 10.0f; public float throwPower = 25.0f; public float RayDistance = 3.0f; public LayerMask layerMask; private bool grab, drop = false; public Transform pos; public float adjust; Rigidbody obj; void Update () { if (Input.GetKeyDown(KeyCode.Mouse1)) { RaycastHit hit; if(Physics.Raycast(transform.position, transform.forward, out hit, RayDistance, layerMask.value)) { Pickable pickable = hit.collider.GetComponent<Pickable>(); if(pickable) { grab = true; obj = hit.rigidbody; obj.isKinematic = true; obj.GetComponent<Collider>().enabled = false; obj.transform.parent = pos; } } } if (Input.GetKeyUp(KeyCode.Mouse1)) { if(grab) { StartCoroutine(PrepareToDrop(3f)); } } if (Input.GetKeyDown(KeyCode.Mouse0)) { if(grab) { StartCoroutine(PrepareToDrop(throwPower)); } } if(grab) { obj.transform.position = Vector3.Lerp(obj.transform.position, pos.position + (pos.transform.forward * adjust) - (pos.transform.up * 0.4f), Time.deltaTime * grabPower); obj.transform.rotation = Quaternion.Lerp(obj.transform.rotation, pos.rotation, Time.deltaTime * 5f); } } IEnumerator PrepareToDrop(float power) { RaycastHit hits; while(!drop) { if(Physics.Raycast(transform.position, transform.forward, out hits, 1.5f, layerMask.value)) drop = false; else drop = true; yield return null; } obj.transform.parent = null; obj.isKinematic = false; obj.GetComponent<Collider>().enabled = true; obj.velocity = transform.forward * power; drop = grab = false; } } and here a video of the issue ehere a little video with the default fpskit grabobjects script and the modified obj.GetComponent<Collider>().enabled = true;
  8. YES you are right but sincerly i cannot figured what is the problem.. so i put it in hold for now.. btw really many many thaks for your help-- thanks bro..
  9. nope...all messed up ..i think there is something strange here... bout yur suggestion to remove radar . simply disabled radar gameobject to test.. right?
  10. tried ..same result.
  11. thanks mate but it's all messed the same i test even with you gently provided scrpt and create cube and assigne the player as script and target and this is the result
  12. yes its not this the case.. i' going to find a good asset on the store LOlL
  13. hi and thanks for your effprt and for your new code.. it's seems to work a little better than mine but not good at all.. btw you gave me an hint.. main camera is not the only on the scen of player since it has a weapon camera too.. could this will be a problem'
  14. i tired everything but sincerly cannot figure how t omake indicator to show correct damage position...i think i'm goging to purchase a premade asset from the store
×
×
  • Create New...