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.

Erarnitox

Member
  • Content Count

    351
  • Joined

  • Last visited

  • Days Won

    20

Erarnitox last won the day on June 29

Erarnitox had the most liked content!

Community Reputation

119 Excellent

About Erarnitox

  • Rank
    Member
  • Birthday 07/26/1997

Profile Information

  • Gender
    Male
  • Location:
    Germany
  • Interests
    Unity i guess :D

Contact Methods

Recent Profile Visitors

2,335 profile views
  1. Erarnitox

    Shotgun bullets ?

    that or make it completely seperate. for example do the functionality with raycasts and the optics with one particle system. I think that would be the cheapest way to do it
  2. if compression doesnt work make sure to use a image format with at least 16bit colors .... this can happen when you only have 8bit colors as well. But as OMA suggested this is often a problem that comes with compression... make sure your settings dont get overridden by the quality presets or sth. like that and the settings you provide actually get used. Edit: when this onlly happens on one platform this might be caused by some platform specific option maybe? try to use a different graphics engine maybe?
  3. yeah its actually very simple to do but here you go: using UnityEngine; public class Peek : MonoBehaviour { public Transform cam; public Transform cam2; private float nextPos; private float nextPos2; private float dampVelocity; private float dampVelocity2; void Update() { float newPos = Mathf.SmoothDamp(cam.transform.localPosition.x, nextPos, ref this.dampVelocity, 0.2f); float newPos2 = Mathf.SmoothDamp(cam.transform.localPosition.y, nextPos2, ref this.dampVelocity2, 0.2f); float newPos3 = Mathf.SmoothDamp(cam2.transform.localPosition.x, nextPos, ref this.dampVelocity, 0.2f); float newPos4 = Mathf.SmoothDamp(cam2.transform.localPosition.y, nextPos2, ref this.dampVelocity2, 0.2f); cam.transform.localPosition = new Vector3(newPos, newPos2, cam.transform.localPosition.z); cam2.transform.localPosition = new Vector3(newPos3, newPos4, cam2.transform.localPosition.z); if (Input.GetKey("x")) { nextPos = 0.7f; nextPos2 = 0.0f; } else if (Input.GetKey("z")) { nextPos = -0.7f; nextPos2 = 0.0f; } else if (Input.GetKey("c")) { nextPos = 0.0f; nextPos2 = 0.0f; } else { nextPos = 0.0f; nextPos2 = 0.0f; } } /* [RPC] //Rpcs are not supported anymore since raknet got removed from unity use UNET or some other networking soulution (TNet is like raknet if you want a quick convert) void Test() {} */ } by the way i would not use the code the way it is it looks hacked together and will be pretty inperformant. Also there are no Remote procedure calls like that anymore, if you want to have networked methods you have to do it differently, wrote a quick comment on the side.
  4. hey there i made a small script and it should only transition between cameras when the room was entered. The first 2-3 times it always works but then it wouldnt work and work sometimes again. here is a video of the problem: and here is the script just without the debug output (debug log in video gets called on trigger enter) using UnityEngine; public class CameraMove : MonoBehaviour { private Transform mainCamera; [Header("Where should the Camera be placed in the Room:")] public Transform cameraPosition; private Vector3 startPos; private Quaternion startRot; private float completion; private bool lerp = false; void Start() { mainCamera = GameObject.FindWithTag("MainCamera").transform; } void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { startPos = mainCamera.position; startRot = mainCamera.rotation; completion = 0; lerp = true; } } private void Update() { if (lerp) { if (Vector3.Distance(cameraPosition.position, startPos) > 0.1f) { completion += Time.deltaTime; mainCamera.position = Vector3.Lerp(startPos, cameraPosition.position, completion); mainCamera.rotation = Quaternion.Lerp(startRot, cameraPosition.rotation, completion); } else { lerp = false; } } } } i feel stupid ^^ should be something simple im missing. The script gets assigned to each room, both of them have a box collider which is marked as trigger. Thanks for the help Edit: I have fixed it! If you want you can use the code. Here is the fixed Version: using UnityEngine; public class CameraMove : MonoBehaviour { public static Transform mainCamera; [Header("Where should the Camera be placed in the Room:")] public Transform cameraPosition; private Vector3 startPos; private Quaternion startRot; private float completion; private bool lerp = false; void Start() { mainCamera = GameObject.FindWithTag("MainCamera").transform; } void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { startPos = mainCamera.position; startRot = mainCamera.rotation; completion = 0; lerp = true; } } private void Update() { if (lerp) { if (Vector3.Distance(cameraPosition.position, mainCamera.position) > 0.1f) { completion += Time.deltaTime; mainCamera.position = Vector3.Lerp(startPos, cameraPosition.position, completion); mainCamera.rotation = Quaternion.Lerp(startRot, cameraPosition.rotation, completion); } else { lerp = false; } } } } }
  5. another idea would be to disable the collider and enabling a trigegr object infront of the player that takes case of collisions or a boxcast
  6. yeah, but i dont think that was the problem ... but i have no idea what might be
  7. okay... well i dont think it will change much but here are some last simplifications to slim down room for error: using UnityEngine; public class DamageIndicator : MonoBehaviour { public Texture damageIndicatorTexture; //Private private Vector2 pivotPoint; private float alpha = 0.0f; private float rotationOffset; private Vector3 attackDirection; void OnGUI() { if(alpha > 0){ GUI.color = new Color (1.0f, 1.0f, 1.0f, alpha); Vector2 vector = new Vector2 (((Screen.width / 2) - (damageIndicatorTexture.width / 2)), (Screen.height / 2)); GUIUtility.RotateAroundPivot (rotationOffset, new Vector2 ((Screen.width / 2), (Screen.height / 4))); GUI.DrawTexture (new Rect (vector.x, vector.y, damageIndicatorTexture.width, damageIndicatorTexture.height), damageIndicatorTexture); } } public void AttackFrom(Vector3 dir) { attackDirection = dir; alpha = 3f; } void Update() { if (this.alpha > 0) { this.alpha -= Time.deltaTime; this.UpdateDirection(); } } void UpdateDirection() { if(alpha > 0){ Vector3 rhs = attackDirection - transform.position; rhs.y = 0; rhs.Normalize(); Vector3 forward; forward = transform.forward; float GetPos = Vector3.Dot(forward, rhs); if (Vector3.Cross(forward, rhs).y > 0){ rotationOffset = (1f - GetPos) * 90; } else{ rotationOffset = (1f - GetPos) * -90; } } } }
  8. thats strange tbh. does it get called from somewhre else as well maybe? i really dont know at this point but it pretty confident that the code is okay edit: this is a pretty dumb idea but .... maybe disable the minimap? edit2: most likely its not the minimap but probably sth. real simple... try to disable as much from the scene as possible to make a "clean" environment for testing... maybe you stumble over the thing that causes it?
  9. made some small changes again and now its working fine for me depending on your texture you might want to change the offset variable to something else like Screen.height/4 instead of /2 but that does look better for me i saw u used /4 in your code thats why i did mention that so anyways here is the code: using UnityEngine; public class DamageIndicator : MonoBehaviour { [HideInInspector] public Vector3 attackDirection; public Texture damageIndicatorTexture; //Private private Vector2 pivotPoint; private float alpha = 0.0f; private float rotationOffset; void OnGUI() { if (alpha > 0) { GUI.color = new Color(1.0f, 1.0f, 1.0f, alpha); float offset = Screen.height / 2; Vector2 vector = new Vector2(((Screen.width / 2) - (damageIndicatorTexture.width / 2)), (Screen.height / 2) - offset); GUIUtility.RotateAroundPivot(rotationOffset, new Vector2((Screen.width / 2), (Screen.height / 2))); GUI.DrawTexture(new Rect(vector.x, vector.y, damageIndicatorTexture.width, damageIndicatorTexture.height), damageIndicatorTexture); } } public void AttackFrom(Vector3 dir) { attackDirection = dir; alpha = 3f; } void Update() { if (this.alpha > 0) { this.alpha -= Time.deltaTime; this.UpdateDirection(); } } void UpdateDirection() { if (alpha > 0) { Vector3 rhs = attackDirection - 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 = transform.forward; } } float GetPos = Vector3.Dot(forward, rhs); if (Vector3.Cross(forward, rhs).y > 0) { rotationOffset = (1f - GetPos) * 90; } else { rotationOffset = (1f - GetPos) * -90; } } } } I did also write a small script to test it: using UnityEngine; public class AttackFrom : MonoBehaviour { public DamageIndicator script; public GameObject target; void Update() { script.AttackFrom(target.transform.position); } } the second script is only for debugging but it helped me to figure out the offset that looks right. here a clip of it in action:
  10. if its facing a different direction but i think this is unlikely
  11. well i did some cleaning up to undestand the code better but i hnestly think everything should be fine with your code! i made some small simplifications, maybe give it a try? But it should do the same thing.... also im pretty positive the code should work! I went trough it step by step all the calculations should be right Still here is my version of the script: using UnityEngine; using System.Collections; public class DamageIndicator : MonoBehaviour { [HideInInspector] public Vector3 attackDirection; public Texture damageIndicatorTexture; //Private private Vector2 pivotPoint; private float alpha = 0.0f; private float rotationOffset; void OnGUI() { if(alpha > 0){ GUI.color = new Color (1.0f, 1.0f, 1.0f, alpha); Vector2 vector = new Vector2 (((Screen.width / 2) - (damageIndicatorTexture.width / 2)), (Screen.height / 2)); GUIUtility.RotateAroundPivot (rotationOffset, new Vector2 ((Screen.width / 2), (Screen.height / 2))); GUI.DrawTexture (new Rect (vector.x, vector.y, damageIndicatorTexture.width, damageIndicatorTexture.height), damageIndicatorTexture); } } public void AttackFrom(Vector3 dir) { attackDirection = dir; alpha = 3f; } void Update() { if (this.alpha > 0) { this.alpha -= Time.deltaTime; this.UpdateDirection(); } } void UpdateDirection() { if(alpha > 0){ Vector3 rhs = attackDirection - 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 = transform.forward; } } float GetPos = Vector3.Dot(forward, rhs); if (Vector3.Cross(forward, rhs).y > 0){ rotationOffset = (1f - GetPos) * 90; } else{ rotationOffset = (1f - GetPos) * -90; } } } } You could check if the Main Camera is really the only active camera in the scene Also you could check with a static position like a cube if the indicator alsways points to it (maybe there is a problem with the bullet/ turret position) well good luck with it and hopefully i solved it by accident haha ^^ Edit: wait... i messed sth. up was testing it ^^ haha
  12. give me one second ill check something
  13. if you put all optics under one child you can completely disable the optics object and enable it again so all childern get disabled as well with it.
  14. 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; } } } i just flipped the left/right code part .... maybe that works ... from your video it looks like it might. Just a guess but maybe you somewhere flipped the argument and thus the plane the 2 vectors span is upside down. I will check that later if it works to fix that properly ^^ but use this script first to see if it fixes the problem
  15. tbh. this looks right to me. Might be i overlooked sth. tho. does your Damage Indecator texture point upwards? maybe try to call it from a debug script to test various positions? also try to set adjust manually to see if it starts out at the right position and rotates the way you expect. ... the update position method itself looks from what i see like it should (might have overlooked sth.)
×
×
  • Create New...