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

Everything posted by fpsarmedunity

  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
  15. hi and thanks to both but i solved by myslf with this foreach (SkinnedMeshRenderer renderer in _currentObject.GetComponentsInChildren<SkinnedMeshRenderer>()) { renderer.enabled = false; } where "_currentObject" is the Gameobject that contains the skinned meshes
  16. sadly doesnt work
  17. i tested increasig the alpha value tto show the indicator from the start and with values you can sse in the video i got that
  18. ys damage indicator texture point upwards i really cannot figure how t ocall it for a debug script to test position...
  19. Hi I'm working on my ecamine system for my project an all works fine but i have a little issue when examininig object i want examned object renderer to be disabled and i figured this with this line of code _currentObject.GetComponentInChildren<Renderer>().enabled = false;// ADDon render object on examine enabled after examination: and renenable it after examination with _currentObject.GetComponentInChildren<Renderer>().enabled = true;// ADDon render object on examine enabled after examination: and all works as ecpected but my probme is that my weapons object have many meshes and not a single mesh renderer it tried with GetComponentsInChildren but only the first skinned mesh is disabled for thie gameobject ...how can i solve this?
  20. which is wrong with mine using UnityEngine; using System.Collections; public class DamageIndicator : MonoBehaviour { /// <summary> /// Attack from direction /// </summary> [HideInInspector] public Vector3 attackDirection; /// <summary> /// time reach for fade arrow /// </summary> public float FadeTime = 3; public Texture damageIndicatorTexture; public Color ArrowColor = new Color(0.85f, 0, 0); /// <summary> /// the transform root of player /// </summary> public GameObject target; //Private public Vector2 pivotPoint; public float alpha = 0.0f; public float offset = 350f; public float rotationOffset; /// <summary> /// /// </summary> void OnGUI() { if (this.alpha > 0) { this.offset = Screen.height / 4; GUI.color = new Color(ArrowColor.r, ArrowColor.g, ArrowColor.b, this.alpha); Vector2 vector = new Vector2(((Screen.width / 2) - (this.damageIndicatorTexture.width / 2)), (Screen.height / 2) - this.offset); this.pivotPoint = new Vector2((Screen.width / 2), (Screen.height / 2)); GUIUtility.RotateAroundPivot(this.rotationOffset, this.pivotPoint); GUI.DrawTexture(new Rect(vector.x, vector.y, this.damageIndicatorTexture.width, this.damageIndicatorTexture.height), this.damageIndicatorTexture); } } /// <summary> /// Use this to send a new direction of attack /// </summary> /// <param name="dir">postion of attacker</param> public void AttackFrom(Vector3 dir) { //target = this.transform ; this.attackDirection = dir; this.alpha = 3f; } /// <summary> /// if this is visible Update position /// </summary> void Update() { // Player Clone integration Start if (target == null) if (GameObject.Find("Player")) target = GameObject.Find("Player"); // player clone integration end if (this.alpha > 0) { this.alpha -= Time.deltaTime; this.UpdateDirection(); } } /// <summary> /// update direction as the arrow shows /// </summary> void UpdateDirection() { Vector3 rhs = this.attackDirection - this.target.transform.position; rhs.y = 0; rhs.Normalize(); Vector3 forward; if (Camera.main != null) { forward = Camera.main.transform.forward; } else { if (Camera.current != null) { forward = Camera.current.transform.forward; } else { forward = this.transform.forward; } } float GetPos = Vector3.Dot(forward, rhs); if (Vector3.Cross(forward, rhs).y > 0) { this.rotationOffset = (1f - GetPos) * 90; } else { this.rotationOffset = (1f - GetPos) * -90; } } }
  21. right.. i disabled the UI pickup text from the wepaon manager when player switch wepaon and all seems to work correcly now.. many thanks.. i only have to fix the bug related to the held object distance and can go ahead with interaction system ..(doors ,drawers, switches and so on)
  22. the method is called in the update of the GrabObject script that is placed inside the NoWeapon GameObject of the Player
  23. check and erro is gone but bug remain the same...
  24. error on compile Assets/_Resources/Scripts/GrabObjects.cs(212,24): error CS1525: Unexpected symbol `.', expecting `,', `;', or `='
×
×
  • Create New...