Quantcast
Channel: Questions in topic: "raycast"
Viewing all 5161 articles
Browse latest View live

Allow raycast to skip an object with rigidbody

$
0
0
I have a gameobject on the Ignore Raycast layer that has a box collider 2D and a RigidBody component attached to it. Its child is on another layer and has a trigger collider which I want the raycast to hit. However, the raycast never reaches the child and gets blocked by the Rigidbody of the parent, despite the parent being set on the Ignore Raycast layer and the raycast having a layermask that only interacts with the child's layer. How do I solve this? Thanks.

Debug.DrawRay doesn't show up, but gizmos are on and duration is specified.

$
0
0
After the new update debug rays just stopped working. Gizmos are on in game view. I operate on the HD render pipeline. I specify origin, direction, color (one that is visible), duration (over a second). What are the things I could be forgetting about?

Physics.Raycast Not Working... Kinda

$
0
0
I have three gameobjects (at least that relate to this problem). There's a bullet, there's an enemy, and there's a boss. The bullet is fired from the player, and contains a simple script that simply updates its transform in FixedUpdate by x speed. It also has a box collider. The enemy doesn't have a box collider, and fires a ray out in Update. The ray code looks like this: RaycastHit hit; if(Physics.Raycast(transform.position, -Vector3.forward, out hit, 0.25f)) { if(hit.transform.CompareTag("Bullet")) { //Do thing here. } } The bullet and the enemy both exist on the same plane, I've used Debug.DrawRay to confirm that they line up perfectly and the bullet's box collider is pretty massive so I can't imagine that they're not hitting eachother. But, actually, they are - this part is perfectly fine and the two work as I expect them to. The problem arises when I introduce the boss. The boss has exactly the same raycast script and yet doesn't work at all - every bullet simply flies right through it. I tried sending a Debug.Log and took out the tag check entirely but it never fired. So I know that it's not a tagging problem and that it's just not detecting the bullet at all. This situation is so bare bones that I am quickly running out of things to try. I have been desperately attempting to find the difference between the enemy and the boss that could be causing this and I've come up completely empty. I realize that maybe what I've explained isn't enough to go on to give a concrete answer, but any suggestions would be of great help. Though I've said that there's only a single enemy and a single boss, there's actually multiple of each and the enemies all work while the bosses simply don't. The rest of their script functions fine, just not this. I've combed through each of their scripts trying to find something that might be overriding the raycast in some way but I've come up with nothing. So if anyone has any questions, suggestions, or can help in any way I'd really appreciate it.,

Physics 2d raycaster from EventSystems for overlapped colliders

$
0
0
Hi, I'm trying to use OnPointerEnter from the EventSystems, with the Physics2DRaycaster attached to the camera. The problem is that when 2 objects are overlapped, one is always in front of the other and doesn't allow the OnPointerEnter event to trigger for the one on the back. Normally this is the expected behaviour, but in my case I need the event to trigger on BOTH objects separately. Is there any workaround for this? The layer masks only allow to ignore one or other of the objects, so it's not a solution.

How do I add force to rigidbody when raycast hits it.

$
0
0
I have an enemy (named "Peeker" in the code) fully rigged, with each child being a certain bone. I am trying to make it so that once you shoot the enemy's bone with a raycast, (which I have already programmed successfully) it applies force to whatever bone it hits. Here is my code so far. As you can see I tried to use "rigidbody.Addforce(-transform.forward * 500); " under the public void "takeDamage," but it gives me a red line. ![alt text][1] [1]: /storage/temp/117243-capture.png (btw if you are wondering why the script is called "Peeker_instakill," it is because this script only gives the peeker a health of 1 if you hit this specific bone, making him easily killable for headshots.)

Raycast hits everything on the screen

$
0
0
I want to be able to click on one of the enemies on the screen to Start a Coroutine, but when i test the raycast it hits everything on the screen instead of just hitting the thing i click on which is obviously a problem. I can get it to tell me in the console that it is hitting the object tagged as "Enemy" but if there are more that one enemies on the screen it hits all of them rather than the one I am clicking on Here is the script that goes on the enemy prefab: using UnityEngine; using System.Collections; public class NPC : MonoBehaviour { public GameObject HealthPack; private int moveSpeed = 1; private MovementSpeedManager moveSpeedA; public int Health = 1; public Rigidbody coin; private bool coinHasSpawned = false; public float coinForce = 1f; private PlayerGold goldGain; private PlayerGold totalGold; public int totalGoldNew; private int spawnHealthPackNumber; public Damsell rageMode; private void Awake() { goldGain = GameObject.Find("GoldManager").GetComponent(); totalGold = GameObject.Find("GoldManager").GetComponent(); moveSpeedA = GameObject.Find("MovementSpeedManager").GetComponent(); } private void Start() { totalGold.totalGold = PlayerPrefs.GetInt("TotalGoldNew"); moveSpeed = moveSpeedA.moveSpeedA; } void Update () { transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime); if (Health <= 0 && coinHasSpawned == false) { moveSpeed = 0; Destroy(GetComponent()); Destroy(this.gameObject, 1f); spawnCoin(); coinHasSpawned = true; spawnHealthPack(); } if (Input.GetKeyDown(KeyCode.Mouse0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 100)) { if (hit.collider.tag == "Enemy") { Debug.Log(hit.collider.tag); StartCoroutine(knockback()); } } } } void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { other.GetComponent().playerHealth --; } } private void spawnCoin() { Rigidbody coinInstance = Instantiate (coin, transform.position, transform.rotation) as Rigidbody; coinInstance.AddRelativeForce(new Vector3(0f, coinForce, 0f), ForceMode.Impulse); goldGain.goldGain++; totalGold.totalGold++; totalGoldNew = totalGold.totalGold; PlayerPrefs.SetInt("TotalGoldNew", totalGoldNew); } private void spawnHealthPack() { spawnHealthPackNumber = Random.Range(1, 101); if(spawnHealthPackNumber >= 99) { Instantiate(HealthPack, transform.position, transform.rotation); } } IEnumerator knockback() { moveSpeed = moveSpeed * -3; yield return new WaitForSeconds(0.2f); moveSpeed = moveSpeedA.moveSpeedA; } }

Raycast only returns false?

$
0
0
Hello. Quick summary of what I'm trying to do: Choose a card with the touchpad of the Vive controller, choose a place on a wall, attach the card to the wall. My plan so far: Add a "Wall" layer to the Wall and a "Card" layer to the cards. Use a Raycast once to check if a Card was selected, Raycast again to check if the Wall got selected. Then move the Card to the position. This is my code so far: public class LaserToWall : MonoBehaviour { public SteamVR_TrackedObject trackedObj; private SteamVR_Controller.Device device; RaycastHit card_hit; RaycastHit wall_hit; Vector3 controllerForward; int cards_mask; int walls_mask; // Use this for initialization void Awake () { controllerForward = trackedObj.transform.forward; cards_mask = LayerMask.GetMask("Card"); walls_mask = LayerMask.GetMask("Wall"); } // Update is called once per frame void Update () { device = SteamVR_Controller.Input((int)trackedObj.index); if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { Ray firstRay = new Ray(trackedObj.transform.position, controllerForward); if(Physics.Raycast(firstRay, out card_hit, float.PositiveInfinity, cards_mask)) { Debug.Log("Card was selected"); } else { Debug.Log("No Card selected"); } } if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && card_hit.collider != null) { Ray secondRay = new Ray(trackedObj.transform.position, controllerForward); Physics.Raycast(secondRay, out wall_hit, float.PositiveInfinity, walls_mask); if (wall_hit.transform.tag == "Rolerow") { //Move the card } } } } However, I always get the "No Card selected" message, even if I select a card! Is something wrong with my code?

RaycasthitAll specific object and its children

$
0
0
Basically, I want to raycast an specific object and its children without layers and / or tags. Therefore, I used RaycasthitAll to iterate through each item of the object. Code: RaycastHit[] hits = Physics.RaycastAll(cam.ScreenPointToRay(Input.mousePosition), 100, hitMask); if (hits.Length != 0) { for (int i = 0; i < hits.Length; i++) { foreach (var obj in myObject.GetComponentsInChildren()) { if (hits[i].collider.transform.Equals(obj)) { // code } } } } else { // revert, or other functionality } If the mouse cursor hits the object and its children, it will execute the first part of the code. If the cursor hits nothing, the second part. *But* the problem here is, if the cursor hits anything (like walls, ground, etc. anything), it will still execute the first part. Therefore I added this: if (hits[i].collider.transform.Equals(obj)) { // code } else { // other code } However, this only works if the cursor is over the last child of the object. *If anything is not clear enough, I can provide more information*

Obstacle Avoidance in Unity, using raycasts. C#

$
0
0
I am using some rudimentary obstacle avoidance algorithm to avoid obstacles, however i am having issues with the right and left sensors. When both are active. they will cancel their rotations and not rotate at all. Also having a bit of trouble figuring out hit.normals via the front sensor. ray = new Ray(transform.position + Vector3.up, transform.forward); Vector3 posInicial = transform.position; float speed = 10f; if (Physics.Raycast(ray, out hit, 55f)) // Front sensor { if (hit.collider.tag == ("Pick Up")) // If robot detects pick up, it goes towards it { Debug.DrawLine(ray.origin, hit.point, Color.red); transform.position = Vector3.MoveTowards(transform.position, hit.point, Time.deltaTime * speed); } else { transform.Rotate(0, -80 * Time.deltaTime, 0); // Rotate if front sensor doesn't detect pick up Debug.DrawLine(ray.origin, hit.point, Color.blue); } } else { transform.position += transform.forward * speed * Time.deltaTime; // Go forward Debug.DrawLine(ray.origin, hit.point, Color.white); } if (Physics.Raycast(posInicial, Quaternion.AngleAxis(45f, transform.up) * transform.forward, out hit2, 20f)) { transform.Rotate(0, -80 * Time.deltaTime, 0); // Rotate left if right detected Debug.DrawLine(posInicial, hit2.point, Color.yellow); } if (Physics.Raycast(posInicial, Quaternion.AngleAxis(-45f, transform.up) * transform.forward, out hit3, 20f)) { transform.Rotate(0, 80 * Time.deltaTime, 0); // rotate right if detected left Debug.DrawLine(posInicial, hit3.point, Color.cyan); } }

oculus go controller transform.forward is giving unexpected behaviours

$
0
0
I have a linerenderer in my controller object with the first point set at the transform.position of the controller and the second at transform.forward * 10, ![alt text][1] i fixed that part by adding an empty gameobject i called anchor to it and rotating it a little so the line will go straight. but when i now try to pick up an object by setting the transform.position to achor.transform.forward * 10 i get this. ![alt text][2] this is the code i'm using, i really hope someone can help me with this annoying problem. using System.Collections; using System.Collections.Generic; using UnityEngine; public class PickUpObjects : MonoBehaviour { GameObject pickedUpObject = null; public Transform anchor; float dist; public LineRenderer line; private void Update() { line.SetPosition(0, transform.position); if(pickedUpObject == null && OVRInput.GetDown(OVRInput.Button.One)) { Debug.Log("DpadUp Pressed"); //raycast to see if it hit something RaycastHit hit; Ray ray = new Ray(transform.position, anchor.forward); if(Physics.Raycast(ray, out hit)) { GameObject hitObject = hit.collider.gameObject; //check if the hit object is pickupable if (hitObject.GetComponent()) { //pickUp pickedUpObject = hitObject; dist = Vector3.Distance(transform.position, hitObject.transform.position); Rigidbody rig = hitObject.GetComponent(); rig.velocity = Vector3.zero; rig.angularVelocity = Vector3.zero; rig.useGravity = false; pickedUpObject.transform.position = anchor.forward * dist; } } } RaycastHit hitRay; Ray rayLine = new Ray(transform.position, anchor.forward); if (Physics.Raycast(rayLine, out hitRay, 10)) { line.SetPosition(1, hitRay.point); } else { line.SetPosition(1, anchor.forward * 10); } if (pickedUpObject != null) { //follow pickedUpObject.transform.position = anchor.forward * dist; } } } [1]: https://i.redditmedia.com/vOskdD-m6D3CTD-GKzH1FvBCaMv3XsEdeuu7GJWw6c0.jpg?w=902&s=4dcac22b9bc5e70e4b91c83178f908a9 [2]: /storage/temp/117415-test.jpg

The controller.move does not work correctly

$
0
0
Hello, I have a problem in my code, I want to move my character with the CharacterController to a specific point on the ground. The problem is in: _Controller.Move (Vector3.Lerp (_PositionOrigin, _PositionDestination, speedMove * Time.deltaTime)); , the character does not go to the indicated point. The transform.position = vector3.MoveTowars, just makes the movement as I want, but with that method you can not detect collisions. What can I do to fix the movement with the CharacterController? and that moves just like the MoveTowars? using System.Collections; using System.Collections.Generic; using UnityEngine; public class MoveInter : MonoBehaviour { public Vector3 _PositionOrigin; public Vector3 _PositionDestination; private bool _IsActive; private string taged; public Animator _Animate; public GameObject origin; public CharacterController _Controller; public Vector3 _PositionHelp; private Vector3 lookAtTarget; private Quaternion playerRoot; public float speedRoot; public float speedMove; void Start () { _IsActive = false; _Animate = origin.GetComponent(); _Controller = GetComponent(); _PositionOrigin = transform.position; } void Update () { _PositionHelp = transform.position; if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if(Physics.Raycast(ray, out hit)) { _IsActive = true; _PositionDestination = hit.point + (hit.normal * transform.localScale.y / 25.0f); taged = hit.collider.gameObject.tag; lookAtTarget = new Vector3(_PositionDestination.x - transform.position.x, transform.position.y, _PositionDestination.z - transform.position.z); playerRoot = Quaternion.LookRotation(lookAtTarget); } } if (_IsActive) { if (taged == "Floor") { //transform.position = Vector3.MoveTowards(_PositionOrigin, _PositionDestination, speedMove * Time.deltaTime); //transform.LookAt(_PositionDestination); transform.rotation = Quaternion.Slerp(transform.rotation, playerRoot, speedRoot * Time.deltaTime); _Controller.Move(Vector3.Lerp(_PositionOrigin, _PositionDestination, speedMove * Time.deltaTime)); } else if (taged == "EnemyCh") { transform.rotation = Quaternion.Slerp(transform.rotation, playerRoot, speedRoot * Time.deltaTime); _Controller.Move(Vector3.Lerp(_PositionOrigin, _PositionDestination, speedMove * Time.deltaTime)); } else if(taged != "Floor" && taged != "EnemyCh") { _IsActive = false; _PositionDestination = _PositionOrigin; } } if(_PositionHelp==_PositionDestination) { _Animate.SetBool("Walk", false); _Animate.SetBool("Atack", false); } else { _Animate.SetBool("Walk", true); _Animate.SetBool("Atack", false); } } private void OnControllerColliderHit(ControllerColliderHit hit) { Debug.Log("collsion"); if (hit.collider.gameObject.tag == "EnemyCh" || hit.collider.gameObject.tag == "Character") { _PositionHelp = _PositionOrigin; Debug.Log("collsion"); _Animate.SetBool("Atack", true); } } }

How to select a specific collider of many on a gameobject?

$
0
0
I have an AI with 3 colliders. 1. On the AI's body only. 2. 10 units around the AI 3. 20 units around the AI I have a player that shoots the AI to reduce it's health. The problem is when the player shoots the AI it registers the hits on the outer collider first (3). Is there a way to identify what collider I want the raycast to use to register a hit? Thanks in advance.

Specific which collider of many on a GameObject to register a hit with RayCast.

$
0
0
I have an AI with 3 colliders. 1. On the AI's body only. 2. 10 units around the AI 3. 20 units around the AI I have a player that shoots the AI to reduce it's health. The problem is when the player shoots the AI it registers the hits on the outer collider first (3). Is there a way to identify what collider I want the raycast to use to register a hit? Thanks in advance.

Obstacle Avoidance in Unity, using raycasts. C#

$
0
0
I am using some rudimentary obstacle avoidance algorithm to avoid obstacles, however i am having issues with the right and left sensors. When both are active. they will cancel their rotations and not rotate at all. Also having a bit of trouble figuring out hit.normals via the front sensor. ray = new Ray(transform.position + Vector3.up, transform.forward); Vector3 posInicial = transform.position; float speed = 10f; if (Physics.Raycast(ray, out hit, 55f)) // Front sensor { if (hit.collider.tag == ("Pick Up")) // If robot detects pick up, it goes towards it { Debug.DrawLine(ray.origin, hit.point, Color.red); transform.position = Vector3.MoveTowards(transform.position, hit.point, Time.deltaTime * speed); } else { transform.Rotate(0, -80 * Time.deltaTime, 0); // Rotate if front sensor doesn't detect pick up Debug.DrawLine(ray.origin, hit.point, Color.blue); } } else { transform.position += transform.forward * speed * Time.deltaTime; // Go forward Debug.DrawLine(ray.origin, hit.point, Color.white); } if (Physics.Raycast(posInicial, Quaternion.AngleAxis(45f, transform.up) * transform.forward, out hit2, 20f)) { transform.Rotate(0, -80 * Time.deltaTime, 0); // Rotate left if right detected Debug.DrawLine(posInicial, hit2.point, Color.yellow); } if (Physics.Raycast(posInicial, Quaternion.AngleAxis(-45f, transform.up) * transform.forward, out hit3, 20f)) { transform.Rotate(0, 80 * Time.deltaTime, 0); // rotate right if detected left Debug.DrawLine(posInicial, hit3.point, Color.cyan); } }

How to access component that the raycast hit

$
0
0
I'm basically wondering how to access a rigid body from the bone that gets hit by the raycast, that way I can apply force to it once it gets shot. How would I implement this in code?

Ray not going to correct position

$
0
0
Questions that may already have your answer: So in my game, I have a grappling hook as the main mode of transport, for this grappling hook to work I need to draw a ray from my player to where my mouse is. I have this working correctly, for the most part, it finds my mouse position and draws a ray there, however the ray doesn't go to the mouse (See Pic Below). ![![alt text][1] [1]: /storage/temp/117812-screenshot-6.png The green line is where it should be going but the red line is where it is. These are different because the red one is a DrawRay and the green is a DrawLine. Does anyone know how to get the ray going to the draw line point?

Linecast detects gameObject underneath the collided one

$
0
0
Ive been looking over my code and using other questions answers and using the documentation to figure this one out but I can't find anything. Basically I got a few rows on objects stacked on top of each other and I am using linecast to detect and destroy them when the player runs into them. I've tried just isolating the collided game object into a gameobject variable, tried making the box collider smaller. Nothing seems to work This is what happens (Keep an eye on the 2 highlighted object names in the Hierarchy): https://youtu.be/JPA82gzD3Ts I've been using various stages of this particular code, this is the latest iteration: void OnCollisionEnter2D(Collision2D collEnter) { if (Input.GetKey ("a") && checkLeft == true && checkBtm == false) { countDown -= Time.deltaTime; print (countDown); collEnter.gameObject.name = "Test"; spr = collEnter.gameObject.GetComponent ().sprite; if (countDown <= 0) { print (spr); Destroy (collEnter.gameObject); } } } I should note that `checkLeft` and `checkBtm` relate to the 2 of the 3 Linecasts I have assigned to the player and this is currently placed in a OnCollisionEnter2D. I have worked out that the player seems to somehow first collide with the object underneath the object I am looking to destroy, I found this out by using `print(collEnter.collider);`. I'd love some feedback on how to fix this issue as I am completely stuck. I originally had this fixed by using a bunch of tags and y lvl iterations in my code but that got to be a pain in the ass for assigning new tags and it would have gotten even worse as I wasn't even a 3rd of the way through with that. EDIT: Additional information as requested. Linecast is implemented in the Update function like this `checkLeft = Physics2D.Linecast (leftStart.position, leftEnd.position);`. I havent get up a Raycast (but I will do that now, I thought I originally did. So that might just fix all my issues, I'll edit this again if that proves to be true) and The body of the player is is on Layer 2 while the GameObjects I am Destroying are on Layer 1 (Honestly didn't consider this an issue).

How do I specify the origin and end points of the arc1 instantiated line?

$
0
0
The bolt material attached to arc1 spawns at the hand and goes the correct direction most of the time but sometimes it shoots randomly off into space and doesn't instantiate at the hand directly either. This is a script for a basic lightning bolt spell. Any other approaches for a lightning bolt would also be welcome as I am having issues with the line renderer. using System.Collections; using System.Collections.Generic; using UnityEngine; public class LightningShooting : MonoBehaviour { //Debug.Log("1"); public float range = 100f; public float timeBetweenBullets = 0.15f; public float effectsDisplayTime = 0.2f; public int lengthOfLineRenderer = 100; float timer; Ray shootRay; RaycastHit shootHit; int shootableMask; //[SerializeField] //public Animator arcAnim2; [SerializeField] private ParticleSystem sparksCast; [SerializeField] private LineRenderer arc1; [SerializeField] private AudioSource thunderAudio1; [SerializeField] private Light flashCast; [SerializeField] public int damagePerShot = 50; void Awake () { shootableMask = LayerMask.GetMask("Shootable"); //layer of "Shootable" objects arc1.positionCount = 2; } void Update() { timer += Time.deltaTime; // sets up the timer if (Input.GetKeyDown(KeyCode.Alpha2) && timer >= timeBetweenBullets) //if the fire key is pressed and the is timer is also less than timebetweenbullets { Shoot(); //defined below } } void Shoot () //what happens when shoot is called { timer = 0f; //reset timer Debug.Log("shoot"); Instantiate (sparksCast, gameObject.transform.position, Quaternion.identity); //emit fromt he particle system Instantiate(flashCast, gameObject.transform.position, Quaternion.identity); //light on player on Instantiate(thunderAudio1, gameObject.transform.position, Quaternion.identity); // plays audio Instantiate(arc1, gameObject.transform.position, Quaternion.identity); // line for animation placheolder //Instantiate(arcAnim2, gameObject.transform.position, Quaternion.identity); Vector3[] points = new Vector3[lengthOfLineRenderer]; shootRay.origin = transform.position; //moves ray for ray cast shootRay.direction = transform.forward; // sets forward to positive z if (Physics.Raycast (shootRay, out shootHit, range, shootableMask)) //if you hit something in the layer "Shootable" { EnemyHealth enemyHealth = shootHit.collider.GetComponent(); //look for script enemyhealth if(enemyHealth != null) //if the object isn't a player { enemyHealth.TakeDamage(damagePerShot, shootHit.point); //take damage, create a point to plac eblood splatter etc. } arc1.SetPosition(1, shootHit.point); //draws line for line renderer } else //if not on the shootable layer... { arc1.SetPosition(1, shootRay.origin + shootRay.direction * range); // set the end point to extent of range } } }

Raycast with doubleCollider

$
0
0
Hi,sorry for my english. I am building a third person shooter. On enemy target i have a double collider, Capsule collider for the enemy mesh and a sphere collider for the aggrozone(on the same object(enemy)). When i shoot of course my raycast hit the aggrozone and decrease the enemy's life. How can ignore the first collider?Please help me, i am going crazy. Ray ray=Camera.main.ViewportPointToRay(Vector3.one*0.5f); Debug.DrawRay (ray.origin, ray.direction * 100, Color.red, 2f); RaycastHit hitinfo; if (Physics.Raycast (ray, out hitinfo, 100)) { var health = hitinfo.collider.GetComponent (); if (health != null) { health.takedamage (damage); print(hitinfo.collider.gameObject.name); } else print(hitinfo.collider.gameObject.name);

Vector3.ProjectOnPlane Undefined at 90 degrees?

$
0
0
Hello everyone. I'm currently in the middle of getting a character to run on walls and ceilings. As of right now, I'm just raycasting downwards and setting the character's rotation relative to the normal of the surface that he is standing on. For the player's movement, I'm basically just converting the input vector of the joystick (Resides on a flat horizontal plane) and making it perpendicular to the normal of the surface via Vector3.ProjectOnPlane. After the method, I make sure to: `ConvertedVector.normalized * OriginalInputVector.magnitude` **since the steeper the slope gets, the lower the converted magnitude becomes.** This works perfectly fine until it gets close to a 90-degree surface. It sort of freaks out. When the wall is at a perfect 90-degrees to the ground, the vector is zeroed. When it goes past 90-degrees, the vector is inverted. Naturally, I added a couple if elses to try and fix this. If the normal had zero y, then I would add .1f to get the movement vector back. And if the normal was less than zero y (greater than 90-degreees), I would invert the result of the direction. These work fine... in very specific situations. But if the surface is spun around on the y axis, then the movement vector goes all over the place. **If I did a horrible job at explaining, just watch this gif.** https://gfycat.com/RecklessVapidHammerheadbird The first part of the gif shows how the vector disappears at 90-degrees. The second part of the gif shows the vector getting inverted past 90-degrees. The end of the gif shows the vector going all over the place when the surface is spun around on the y axis. (This last part I have not actually tested walking over with the player controller yet, but by eyeballing it, it looks off.) So in short, I want the converted vector to be usable when it gets close to 90-degrees and exceeds it. Thanks for all who can help!
Viewing all 5161 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>