Questions in topic: "geometry"
http://answers.unity.com/questions/topics/single/1488.html
The latest questions for the topic "geometry"How can i get the center of intersection of two capsules
http://answers.unity.com/questions/1902046/how-can-i-find-center-of-intersection-of-two-meshe.html
<br>
How can i find center of intersection of two capsules?
<br>
Is there some math or algorithms that can help me in terms of tasks like that?
<br>
![alt text][1]
<br>
[1]: /storage/temp/196315-untitle1d.pngc#meshgeometrySat, 14 May 2022 08:25:28 GMTfast35890How do I get the color of a certain mesh vertex?
http://answers.unity.com/questions/1900167/how-do-i-get-the-color-of-a-certain-mesh-vertex.html
I have a custom mesh and I want to get the color of a separate triangle. I tried to use these solutions : https://stackoverflow.com/questions/45854076/set-color-for-each-vertex-in-a-triangle , https://stackoverflow.com/questions/57405631/unity-how-to-use-mesh-triangleindex-to-recolor-a-triangle-when-clicked?rq=1 . I don't have a texture on the object, so there remains only a way with manipulations of triangles and vertices. I was trying to get the color this way :
// Update is called once per frame
void Update()
{
Ray ray = camera.ScreenPointToRay(Input.mousePosition);
RaycastHit[] hitInfos = Physics.RaycastAll(ray);
// Debug.Log(hitInfos[0].collider.GetComponent<MeshFilter>
().mesh.triangles[hitInfos[0].triangleIndex]);
Debug.Log(hitInfos[0].collider.GetComponent<MeshFilter>().mesh.colors.Length);
}
public static int GetSubMeshIndex(Mesh mesh, int triangleIndex)
{
if (mesh.isReadable == false)
{
Debug.LogError("You need to mark model's mesh as Read/Write Enabled in Import Settings.", mesh);
return 0;
}
int triangleCounter = 0;
for (int subMeshIndex = 0; subMeshIndex < mesh.subMeshCount; subMeshIndex++)
{
var indexCount = mesh.GetSubMesh(subMeshIndex).indexCount;
triangleCounter += indexCount / 3;
if (triangleIndex < triangleCounter)
{
return subMeshIndex;
}
}
Debug.LogError(
$"Failed to find triangle with index {triangleIndex} in mesh '{mesh.name}'. Total triangle count: {triangleCounter}",
mesh);
return 0;
}
}
But this did not give any result because the array is emptycolorverticestrianglesgeometryMon, 02 May 2022 19:21:53 GMTLorandiusHow to shoot many raycasts il all directions except the ground ?
http://answers.unity.com/questions/1899453/how-to-shoot-many-raycasts-il-all-directions-excep.html
Hi !
I've been trying to reproduce a adaptive echo system for my game based on this demo from Rory Walker I found : https://youtu.be/9vmtm7ed3Z8?t=441. What I am trying to do is **to get an average value of the distance between the player and the sum of all of the hit points**.
Being a newbie in programming, I tried my best to get an effective system by searching on various forums how to shoot raycasts **in all directions except the floor**.
I managed to get my system to work but the problem is that in the code I copied, the raycasts are shot **in all directions including the floor**. The reason why I need the rays to only hit what is above a certain vertical angle is because my player is a third person character and my listener (and my script) **are attached to the camera, which distance from the ground can vary and then affect the average distance I'm passing to fmod**, which could lead to some non realistic behaviour where the calculated average distances could be nearly the same in a big open field and in a closed room in function of how high is placed the camera.
Also I am totally incompetent in everything including math and geometry, and I guess that the solution in my code reside in my **GetDirections()** function, but unfortunately, I don't have the knowledge to adapt those calculations to my needs.
Thank you for your time !
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class RS_AudioEcho : MonoBehaviour
{
private RS_Camera m_camera = null;
private const int m_directionCount = 16;
private const int m_maxDistance = 500;
private int m_facticeSandlayerMask = 1 << 24;
private float m_averageDistance;
private static int m_rayCount = -1;
private static float m_distancesTotalValue = 0.0f;
private static float m_distancesAverageValue = 0.0f;
private void Awake()
{
m_camera = FindObjectOfType<RS_Camera>();
}
public float GetDistanceToGround()
{
List<float> distances = new List<float>();
m_rayCount = -1;
m_distancesTotalValue = 0.0f;
foreach (var direction in GetDirections(m_directionCount))
{
RaycastHit hitInfo;
if (Physics.Raycast(transform.position, direction, out hitInfo, m_maxDistance, m_facticeSandlayerMask))
{
distances.Add(hitInfo.distance);
Debug.DrawRay(transform.position, direction, Color.green);
m_rayCount ++;
m_distancesTotalValue = m_distancesTotalValue + hitInfo.distance;
}
}
return distances.Any() ? distances.Min() : m_maxDistance;
distances.Clear();
}
private Vector3[] GetDirections(int numDirections)
{
var pts = new Vector3[numDirections];
var inc = Mathf.PI * (3 - Math.Sqrt(5));
var off = 2f / numDirections;
foreach (var k in Enumerable.Range(0, numDirections))
{
var y = k * off - 1 + (off / 2);
var r = Math.Sqrt(1 - y * y);
var phi = k * inc;
var x = (float)(Math.Cos(phi) * r);
var z = (float)(Math.Sin(phi) * r);
pts[k] = new Vector3(x, y, z);
}
return pts;
}
void Update()
{
m_distancesAverageValue = m_distancesTotalValue / m_rayCount;
GetDistanceToGround();
// Debug.Log(m_rayCount);
// Debug.Log(m_distancesTotalValue);
//Debug.Log(m_distancesAverageValue);
}
}raycastmathraycasthitgeometryraysWed, 27 Apr 2022 23:06:51 GMTNijemiSlice a mesh in different gameobjects
http://answers.unity.com/questions/1898836/slice-a-mesh-in-different-gameobjects.html
Hi!
I've a very long mesh, and I want to slice this mesh in three differents parts, more precisely I want to cut this mesh at z = 18 and z = 28 and obtain three different gameObjects.
How can I do?geometrySat, 23 Apr 2022 15:46:50 GMTTTuPCHow do I calculate the arc of a throw, given two positions and an angle of attack?
http://answers.unity.com/questions/1887792/how-do-i-calculate-the-arc-of-a-throw-given-two-po.html
**I want to save you many hours of research and hours going through physics calculations**
<br><br>
**PROBLEM:**<br>
I have a player on the screen and he moves around a cross-hair target across the ground to the location where he wants to attack another object/player. All I want to tell the ball is where the destination is and what the degree-angle into the air I want to throw the ball and I want the ball do to the rest of the calculations.<br><br>
**SETUP:**<br>
Create a script called "ThrowArcBehavior", then create a sphere and apply this script to that sphere..... That's it!!!<br><br>
You could of course, adjust the gravity, the angle, or anything else, but this should help to get you started!<br><br>
**SPECIAL THANKS TO:**<br>
ShervinM, who helped to provide the basis for this code in 3d geometry. Original 2d code and the conversation can be found here: [Link To Webpage][1]
<br><br>
**CODE:**<br><br>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ThrowArcBehavior : MonoBehaviour
{
//Gravity of the simulation
public float gravity = 9.8f;
// save CPU resources by only running the code when InFlight=true
public bool inFlight;
// the angle thrown into the air
public float targetInclination;
// the destination of our target
public Vector3 targetDestination;
// IF RUNNING COLLISSIONS ie: if you want to trigger something like "send a message to the player if the ball or rock hits him"
// the radius to send the collission message
public float radiusToTrigger;
// the layerMask to check for collissions.
private LayerMask layerToCheck;
private Vector3 startPosition;
private float xVelocity;
private float yVelocity;
private float flightDuration;
private float elapsedTime;
// Start is called before the first frame update
void Start()
{
// IF THIS is a Stand-Alone test then run this code below....
// Vector3 testDestination = new Vector3 (5f,1f,5f);
// Initialize (45f, testDestination, 5f, LayerMask.GetMask("default"));
inFlight = true;
startPosition = transform.position;
elapsedTime = 0f;
CalculateVariables();
}
// Update is called once per frame
void Update()
{
if (inFlight)
{
UpdateProjectilePosition();
}
}
public void Initialize(float inclination, Vector3 destination, float radiusOfTrigger, LayerMask layerToCheckAgainst)
{
targetInclination = inclination;
targetDestination = destination;
radiusToTrigger = radiusOfTrigger;
layerToCheck = layerToCheckAgainst;
inFlight = true;
}
public void CalculateVariables()
{
// CALCULATIONS if there are DIFFERENT START and END HEIGHTS
// Calculate the range from the projectile to the target by zero-ing each out in their y-axis
Vector3 zeroedOrigin = new Vector3(startPosition.x, 0, startPosition.z);
Vector3 zeroedTarget = new Vector3(targetDestination.x, 0, targetDestination.z);
Vector3 zeroedDirection = (zeroedTarget - zeroedOrigin).normalized;
float angleRad = targetInclination * Mathf.Deg2Rad;
float heightDifference = startPosition.y - targetDestination.y;
float targetDistance = Vector3.Distance(transform.position, targetDestination);
float targetRange = Vector3.Distance(zeroedOrigin, zeroedTarget);
// Calculate the velocity needed to throw the object to the target at specified angle.
// Velocity can be solved by re-arranging the general equation for parabolic range:
// https://en.wikipedia.org/wiki/Range_of_a_projectile
float projectile_Velocity
= (Mathf.Sqrt(2) * targetRange * Mathf.Sqrt(gravity) * Mathf.Sqrt(1 / (Mathf.Sin(2 * angleRad)))) /
(Mathf.Sqrt((2 * targetRange) + (heightDifference * Mathf.Sin(2 * angleRad) * (1 / Mathf.Sin(angleRad)) * (1 / Mathf.Sin(angleRad)))));
// Extract the X Y componenent of the velocity
xVelocity = projectile_Velocity * Mathf.Cos(angleRad);
yVelocity = projectile_Velocity * Mathf.Sin(angleRad);
// Calculate flight time.
flightDuration = targetRange / xVelocity;
// Rotate projectile to face the target.
transform.rotation = Quaternion.LookRotation(zeroedDirection);
}
public void UpdateProjectilePosition()
{
if (elapsedTime >= flightDuration)
{
// if we finished our our flight/trajectory of the item thrown, then lets end it
ProjectileLanded();
return;
}
// However if NOT enough time has elapsed to complete the arc throw....
float x = 0f;
float y = (yVelocity - (gravity * elapsedTime)) * Time.deltaTime;
float z = xVelocity * Time.deltaTime;
// May need to switch around Z and X axis depending on the "forward-direction" of the object
this.transform.Translate(x, y, z);
elapsedTime += Time.deltaTime;
}
public void ProjectileLanded()
{
Debug.Log("This Projectile Landed");
inFlight = false;
//Physics.OverlapSphere ()
}
}
[1]: https://forum.unity.com/threads/throw-an-object-along-a-parabola.158855/physicsmathballgeometryFri, 18 Feb 2022 16:22:24 GMTkarma0413Create spheres on the vertices of a Cube
http://answers.unity.com/questions/1884729/create-spheres-on-the-vertices-of-a-cube.html
I'm quite new to Unity here and I have been trying to draw a couple of spheres on the vertex of a Cube gameobject. The code is as follows
public GameObject Elements;
public float gapWidth = 0.01f;
void Start()
{Elements = GameObject.CreatePrimitive(PrimitiveType.Cube);
Elements.name = "Ele1";
Elements.transform.position = new Vector3(0.0f * gapWidth + 0.5f, 0.0f * gapWidth + 0.5f, 0.0f * gapWidth + 0.5f);
Elements.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
Vector3[] vertices = Elements.GetComponent<MeshFilter>().mesh.vertices;
GameObject[] Spheres = new GameObject[vertics.Length];
for (int i = 0; i < vertices.Length; i++)
{
Spheres[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere);
Spheres[i].transform.position = vertices[i];
Spheres[i].transform.localScale -= new Vector3(0.8F, 0.8F, 0.8F);
}
}
- The problem here is that the spheres occur somewhere else in world space and not on the vertices of the Cube. I think I am going wrong somewhere in transform.position. Any help would be appreciated.c#transform.positiongeometryTue, 01 Feb 2022 18:17:42 GMTAnnoyedShepherd12How to convert Open3d camera Pose to unity
http://answers.unity.com/questions/1884509/how-to-convert-open3d-camera-pose-to-unity.html
Greetings!
I've been running thru an issue where I do a camera extrinsic calibration in Open3D with global registration and ICP, the point clouds from each camera get aligned correctly but when I pass the camera pose to unity I get a really bad result. The Open3D Transform seems fine I already inverted the Y axis due to the difference in the coordinate system but I can't figure out where the variation error is coming from, is it just because of imprecision, or I'm missing something.
I invert the transform so I can extract the rotation matrix and the translation vector from the pose. My approach is to get the rotation and the translation and assign them to their correspondent kinect object in unity. The main Kinect stays in the origin of the coordinates and then I apply the transformations to each camera referencing the main one. I'll attach some data and captures of the setup.
I get this transformations in open3d
----------
transformation_1
array([[ 0.96518757, -0.24386752, -0.09455995, -0.30049289],
[ 0.14996032, 0.21974007, 0.9639638 , -0.97258158],
[-0.21430085, -0.94458612, 0.24866084, 0.60323834],
[ 0. , 0. , 0. , 1. ]])
.
transformation_2
array([[ 0.9690198 , 0.23938183, -0.06080263, -0.36967974],
[-0.15101459, 0.37945827, -0.91280119, 1.0112917 ],
[-0.19543595, 0.89370452, 0.40385273, 0.61812839],
[ 0. , 0. , 0. , 1. ]])
----------
After following this write up ( https://plastic-fur-aec.notion.site/Transform-of-coordinate-systems-ef17d83ea3f743d09aff8d8b1e82884d ) I proceed to get the unity translation and rotation as seen in this screenshot
![alt text][1]
----------
When I manually calibrate the cameras in unity I get these vectors, and I really can't figure out if there's any correlation with the ones that I mentioned previously.
![alt text][2]
Any help or tip about what's happening would be greatly appreciated since I've been stuck with this for a long time,
Thanks in advance!
[1]: /storage/temp/191994-captura.png
[2]: /storage/temp/191995-capturaa.pngtransformgeometryconversioncoordinate-systemTue, 01 Feb 2022 09:46:13 GMTunity_66EE57E51196202B06DDHow to find the center of mass from capsulecast
http://answers.unity.com/questions/1860879/how-to-find-the-center-of-mass-from-capsulecast.html
Is there an easy way to find the center of mass from a capsulecast, or should I find the geometric center of it?physicsraycastmathgeometrycapsulecastMon, 13 Sep 2021 21:15:32 GMTRhinoPakCalculating an arc of on ellipse from an internally offset point
http://answers.unity.com/questions/1852664/calculating-an-arc-of-on-ellipse.html
Hey everyone,
I've been struggling a bit with an issue dealing with calculating the arcs of an ellipse. In the attached image you'll see a rectangle surrounded by an ellipse. The ellipse and rectangle share the same center, but both are divided into four quadrants. I am trying to come up with a formula that describes the ellipse's four corresponding arcs, drawn from a point that is offset from the center of the two shapes. I don't have any issues dealing with a circular shape instead of an ellipse as long as the arcs originate in the center instead of being offset. Surely there is some formula out there for drawing an ellipse from any point inside the ellipse? All my searches have come up with just drawing a regular ellipse offset from 0,0, NOT from a point offset internally.
The whole reason for this is to be able to draw a section of shielding around a ship that corresponds to the quadrant it is in.![alt text][1]
[1]: /storage/temp/184322-ellipse-arcs.pnggeometryTue, 03 Aug 2021 16:18:28 GMTstrikenowhereShortest distance between two meshes/colliders
http://answers.unity.com/questions/1851472/shortest-distance-between-two-gameobjects.html
I have two objects with a significant size difference. I want to find the shortest possible distance between those objects. For example, if I have a small chair in front of a wall. I want the distance between the chair and the wall. I tried using `Vector3.distance`, but it calculates using world coordinates. I tried using colliders to achieve this as I had read somewhere that it was the solution but was unclear on how to go about it. Can someone please help?
I have added an image to illustrate what I want. the drawing on the left is of the camera view and the right is a side view. **The red line is the distance I get** when I use `Vector3.Distance`, however **the distance I want is the green line**. If there are many objects in the game, how can I get the shortest distance between the two objects I have selected. I have seen a few solutions but none of them seem to work for me.
![alt text][1]
[1]: /storage/temp/184083-distance.pngc#vector3distancegeometryvector3.distanceWed, 28 Jul 2021 08:34:01 GMTshs2410How to find centers of inner child of a quad (geometry guy needed)?
http://answers.unity.com/questions/1833033/how-to-find-centers-of-inner-child-of-a-quad-geome.html
The same question on the Unity Forum with readable text - https://forum.unity.com/threads/how-to-find-centers-of-inner-child-of-a-quad-geometry-guy-needed.1100416/
Hi, I have not very big experience in the game development sphere (around 4 years), but I have collided with this problem at least 2 times already. And every time I solved it with the stupidest method. Now I have collided with it 3rd time and I need to solve it in a smart way.
Problem description:
Imagine, that we have a plane (quad or rectangle) [img. 1]. We want to split it into 4 children of the same size. We know all about this plane - its dimensions and center position. So we easily calculated the child's plane size and ready to move on. What we need to do next - is to define where we want to place every child. And this is the task - "how to find child plane position in the smartest (and possibly the fastest way)?"
![alt text][1]
The result we want to achieve
![alt text][2]
[1]: https://forum.unity.com/attachments/square-png.842992/
[2]: https://forum.unity.com/attachments/upload_2021-4-27_20-45-8-png.843013/
All next info was based on the concept that we decide that we want to find centers of that small planes.
Solution 1 - Cavemen calculations
The ugliest way to resolve this task. I used it before when I need to resolve this kind of problem. And it works pretty robustly, like stone, that was taped to the stick by our grandgrandgrandfather. But this solution is ugly. It will produce a tone of bugs. It hard-to-modify solution. And it will be even more complicated for 3D.
The code of the solution
public void Split ()
{
Vector3 nodeBoundsExtents = NodeBounds.extents;
float nodeBoundsExtentsX = nodeBoundsExtents.x;
float nodeBoundsExtentsZ = nodeBoundsExtents.z;
Vector3 childBoundsSize = new Vector3(nodeBoundsExtentsX, 0, nodeBoundsExtentsZ);
Vector3 childBoundExtents = childBoundsSize / 2.0f;
Vector3 nodeCenterPosition = NodeBounds.center;
Vector3[] childPositions =
{
new Vector3(nodeCenterPosition.x, 0, nodeCenterPosition.z) - childBoundExtents,
new Vector3(nodeCenterPosition.x, 0, nodeCenterPosition.z) + childBoundExtents,
new Vector3(nodeCenterPosition.x - childBoundExtents.x, 0, nodeCenterPosition.z + childBoundExtents.z),
new Vector3(nodeCenterPosition.x + childBoundExtents.x, 0, nodeCenterPosition.z - childBoundExtents.z)
};
foreach (Vector3 childPosition in childPositions)
{
CreateChild(childPosition, childBoundsSize);
}
}
private void CreateChild (Vector3 centerOfTheNewChild, Vector3 childBoundsSize)
{
GameObject child = new GameObject();
BoxCollider boxTest = child.AddComponent<BoxCollider>();
boxTest.size = childBoundsSize;
child.transform.position = centerOfTheNewChild;
}
This solution is based on one action - we just get the center of the big plane and shift it with offset with size of the small quad in different directions.
Solution 2 - When you try to impress your crush with your math skills
This solution is a bit better than the first, but it has a few cons:
- It doesn't intuitive and it not
stupid and simple
- It can produce strange results when
you will mess with the mirror vector.
- It will become completely messy in
3D.
The code of the solution
public void Split ()
{
Vector3 nodeBoundsExtents = NodeBounds.extents;
float nodeBoundsExtentsX = nodeBoundsExtents.x;
float nodeBoundsExtentsZ = nodeBoundsExtents.z;
Vector3 childBoundsSize = new Vector3(nodeBoundsExtentsX, 0, nodeBoundsExtentsZ);
Vector3 childBoundExtents = childBoundsSize / 2.0f;
Vector3 nodeCenterPosition = NodeBounds.center;
Vector3 firstQuadCenter = new Vector3(nodeCenterPosition.x, 0, nodeCenterPosition.z) - childBoundExtents;
Vector3[] childPositions =
{
firstQuadCenter,
firstQuadCenter * -1,
Vector3.Reflect(firstQuadCenter, Vector3.right),
Vector3.Reflect(firstQuadCenter, Vector3.forward)
};
foreach (Vector3 childPosition in childPositions)
{
CreateChild(childPosition, childBoundsSize);
}
}
private void CreateChild (Vector3 centerOfTheNewChild, Vector3 childBoundsSize)
{
GameObject child = new GameObject();
BoxCollider boxTest = child.AddComponent<BoxCollider>();
boxTest.size = childBoundsSize;
child.transform.position = centerOfTheNewChild;
}
Looks smart, doesn't it? We used magical Vector3.Reflect() and g̶e̶t̶ ̶b̶u̶n̶n̶y̶ ̶o̶u̶t̶ ̶f̶r̶o̶m̶ ̶a̶ ̶h̶a̶t̶ made our code a bit smaller. You can show this code to your crash and she/he will probably let you hug her/him (joke, programmers with girlfriend - it's a myth).
But, what if I want to mirror my start cube by diagonal, but opposite to firstQuadCenter * -1? And I'm sure this will look messy for 3D. However, this code is still pretty robust for 2D. I think this solution is better than the first one, but not the "best practice".
Solution 3 - Dizzy rotation
This solution came to me when I remembered my math lessons about sines and cosines. We can rotate that stuff from 0 to 360 degrees and functions will change their sign.
The code of the solution
public void Split ()
{
Vector3 nodeBoundsExtents = NodeBounds.extents;
float nodeBoundsExtentsX = nodeBoundsExtents.x;
float nodeBoundsExtentsZ = nodeBoundsExtents.z;
Vector3 childBoundsSize = new Vector3(nodeBoundsExtentsX, 0, nodeBoundsExtentsZ);
Vector3 childBoundExtents = childBoundsSize / 2.0f;
Vector3 nodeCenterPosition = NodeBounds.center;
Vector3 firstQuadCenter = new Vector3(nodeCenterPosition.x, 0, nodeCenterPosition.z) - childBoundExtents;
float[] rotateAngles =
{
0.0f,
90.0f,
180.0f,
270.0f
};
Vector3 rotationDirection = firstQuadCenter - nodeCenterPosition;
foreach (float rotateAngle in rotateAngles)
{
Vector3 rotatedDirection = Quaternion.Euler(new Vector3(0.0f, rotateAngle, 0.0f)) * rotationDirection;
CreateChild(rotatedDirection + nodeCenterPosition, childBoundsSize);
}
}
private void CreateChild (Vector3 centerOfTheNewChild, Vector3 childBoundsSize)
{
GameObject child = new GameObject();
BoxCollider boxTest = child.AddComponent<BoxCollider>();
boxTest.size = childBoundsSize;
child.transform.position = centerOfTheNewChild;
}
Smart? - Maybe. Simple? - not really. I believe this is the most uncomfortable and complicated-to-understand solution. Without any comment or image, it is hard to understand why we need to rotate something and where we do this rotation. I don't want to have this code, not in this form at least.
The algorithm of this solution is quite simple - we just rotate the first small quad's center around the big quad's center clockwise (also we can do counterclockwise move). We rotate it with step 90. And here we can find a big disadvantage of this solution - it can be used effectively only for quad, not for the rectangle (every rectangle will have other rotation step value).
Conclusion
So, that's all from my side. I have no more solutions and can't imagine anything new for now. I'm pretty sure that there is a formula or two, that will resolve this geometry problem with 2 lines of robust code.
I will be very happy if you will share your solutions or comments for my and we will find the best solution sooner or later. Or a smart guy will glance on this thread and just say "But we already have the function GameObject.SplitQuadOn4Parts(), check the documentation".c#mathalgorithmgeometryWed, 28 Apr 2021 22:02:26 GMTMagicianArtemkaRotate parent to aim child in 2D
http://answers.unity.com/questions/1821300/rotate-parent-to-aim-child-in-2d.html
What I basically have is a character holding a rifle. What I want to achieve is that, given a point in the world, the character's torso rotates in such a way that the rifle is aiming at the given point.
I tried using the solutions provided for a similar question (but in 3D) and it didn't work. I tried many approaches but I'm afraid my knowledge of geometry is not deep enough to allow me to solve this issue on my own.
Thanks in advance for any help.rotationunity 2daiminggeometryThu, 11 Mar 2021 09:51:58 GMTFVortexProbuilder Fill hole Issue
http://answers.unity.com/questions/1792861/probuilder-fill-hole-issue.html
I am pretty new to using Probuilder and am having an issue with filling a hole in my mesh. It seems like a simple hole (its literally a one-sided/faced rectangle) and I can not for the life of me figure out what is going on. The second image shows the edges I have selected and the setting for the hole. I tried doing the fill for the entire hole and turning that off as well to see if it made any difference. Every time I click fill hole the edges get deselected and nothing gets filled. Am I missing something simple?
Thanks in advance.3dgeometryfillWed, 02 Dec 2020 00:33:32 GMTrekameGet closest point on 2D perimeter using Bounds
http://answers.unity.com/questions/1787626/get-closest-point-on-2d-perimeter-using-bounds.html
I'm using the [Bounds.ClosestPoint][1] to get the closest point on bounds but when inside the bounds you just get the current spot but I want to keep getting a point on the perimeter.
Can anyone throw me the calculations for that?
[1]: https://docs.unity3d.com/ScriptReference/Bounds.ClosestPoint.html2ddistanceboundspointgeometryWed, 11 Nov 2020 10:57:01 GMTPlayCreativelyUsing raycast to sonify point cloud data and geometry of shapes
http://answers.unity.com/questions/1787484/using-raycast-to-sonify-point-cloud-data-of-shapes.html
Hello community,
I am working with the blind and the visually impaired to assist with object identification.
I am looking for development advice for the best approach to sonify shapes with accuracy using sound in a 3D unity scene at runtime.
I have been using existing datasets of simple objects and also iPad Pro and have seen the geometry mesh and point cloud information that can be captured. I am really interested in the communities opinion of how sonification of this data could be approached. I have a procedural and spatial audio background but am struggling with getting the dataset/data to a usable format for audio implementation.
I have looked into volumetric audio, however surfaces don’t have great definition with this method and if blindfolded you could not detect that object shape or detail of edges.
I feel as though a raycast, focused, almost an audio scrubbing method, from FPS view then spatialised would possibly be the best approach, although I want to know your thoughts, I am unsure dev wise how to implement this. Would be great to scan through the point cloud or geometry data and extrapolate it so that I could use those parameters to drive sound. I have attempted to draw this https://share.icloud.com/photos/0o81uJF3vmaz6YM5vOm-efzzQ
I would need to leverage the raw point cloud data or geometry to sonify, I am just really unsure on this and would appreciate any advice on this.
This video is unique but is actually quite interesting in terms of approach, if a user/player had control of this it would be an interesting way for a blind person to inspect a complicated object. https://vimeo.com/195054847
I would want to start with boxes and spheres first and the consideration of someone moving round the object needs consideration also.
Thanks in advance
RraycastaudioruntimedatageometryTue, 10 Nov 2020 21:13:56 GMTRich_XRGenerate 3d Mesh from 2d drawing
http://answers.unity.com/questions/1783977/generate-3d-mesh-from-2d-drawing.html
Hello guys, I try to make a mechanic like in "Draw Climber", the most important thing is creating 3d mesh with collider by 2d drawing on grid from player, for example you draw a circle - and it spawns a 3d sircle with collider. I thought about spawning mutiple cubes like pixels to build some shape, but how to controll it via c#?
I tried to find a solution, but there is only one and It's not for free. From where should I start?grid3d modelalgorithmgeometryalgebraTue, 27 Oct 2020 17:41:38 GMTunity_lSXJSIZAvqe3QwTestPlanesAABB Does not work when looking up.
http://answers.unity.com/questions/1781467/testplanesaabb-does-not-work-when-looking-up.html
In the following simple setup, TestPlanesAABB claims the cube is visible when it is very clearly not. ![alt text][1]
[1]: /storage/temp/169444-screen-shot-2020-10-18-at-32817-pm.png
Steps to recreate:
Camera at (0,0,0) pointing at (-50, 0, 0) (pointing at the sky).
Cube at (0,-2,0) with scale (1, 1, 10) (below the camera).
This [example script from the unity documentation](https://docs.unity3d.com/ScriptReference/GeometryUtility.TestPlanesAABB.html) attached to the cube claims that the cube is visible, when it is very clearly not.
Playing around I notice some strange behaviors like when I change the FOV to be >61 it works, but <=61 it doesn't. It detects the cube at angles -50 and -60, but not at -40 or -70 for some reason.cameracolliderplaneboundsgeometrySun, 18 Oct 2020 22:38:36 GMTluchris429Problems building animation with completely scripted objects - everything is pink!
http://answers.unity.com/questions/1779126/problems-building-animation-with-completely-script.html
Hi.
I'm making an animation for an artist, converting to Unity after 10 years of ActionScript.
It's purely code, there are no assets or materials at all, I use vertices on the fly to create shapes and then colour cycle them.
I'm using UniversalRenderPipelineAsset, and when I run the code, the shapes get a 'Lit (instance)' of shader Universal Render Pipeline/Lit.
![alt text][1]
Works as expected in the editor, but when I build, I just get the default pink for the colours.
Can someone help - I'm thinking of re-making the whole thing in Phaser!!
I obviously need to tell it what I'm using for the build, but can't figure it out.
Here's what I tried:
- Adding a material 'Lit' to a material folder in my assets
- Added all the 'UI/Lit/' options to Always Included Shaders in the Graphics settings
- Checked 'Keep All' in Shader Stripping Instancing Variants
- Little bit of crying.
Thanks.
[1]: /storage/temp/168987-capture.jpgbuild settingspipelinegeometryvertex shadergeometry shaderSat, 10 Oct 2020 19:12:07 GMTFlusteredLondonAdjustable mesh geometry,Create a mesh with adjustable geometry
http://answers.unity.com/questions/1771171/adjustable-mesh-geometrycreate-a-mesh-with-adjusta.html
Hi all!
I am looking to create a game where you can ride a bike through various levels, such as a skatepark.
I would like to make the bike geometry user adjustable (ex. change frame size, wheel size, headtube angle, etc) from some kind of "Bike Creator" menu, kind of like a Character Creator menu. This means that once you create your bike, the geometry is set and couldn't be changed from in level.
I am currently investigating creating a model in Blender and using Bones to define the bike geometry. However I'm not sure if that is the right approach because my understanding is that is usually used for animation.
I am having a tough time figuring out how to accomplish this, and could use some high level guidance to point me in the right direction.
I would appreciate any pointers or tips to set me on my way. Thanks!meshgeometrybikeadjustWed, 16 Sep 2020 19:54:44 GMTnickcamps92Fit in squares in a dedicated space
http://answers.unity.com/questions/1764863/fit-in-squares-in-a-dedicated-space.html
A random number between 2 and 100, What I want to do is;
create a number of squares(doesn't have to be, any shape is ok) that will fit accordingly inside the dedicated
space for them(let's say half of the screen, etc).
if the number is 2, create two squares that are half the space size big.
if the number is 10, create 10 squares 1/10 space size big.
maximum squares per rows and columns are 10...
Example:
![alt text][1]
**How can I achieve something like this, any tutorial or idea?**
[1]: /storage/temp/166126-squares.png2dgraphicsmathgeometrySun, 23 Aug 2020 16:58:04 GMTZozeRHelp with implementing a wall climbing mechanic like botw?
http://answers.unity.com/questions/1761468/help-with-implementing-a-wall-climbing-mechanic-li.html
So I have recently been doing research into how to implement dynamic wall climbing similar to Conan exiles and BOTW. My system as of now uses a raycast to get the direction of a geometry's normal, and I make the player face that. I send another raycast in the direction of the players input, which gets takes the hit point, and lerps the player to that ray's hit position on the geometry. Although this system works well on a flat wall it struggles a lot on complex geometry such as a bumpy cliff, and constantly hangs on small edges. I recently saw this [video][1] from a cancelled game that seems to implement some sort of navmesh by making a flat plane that follows the terrains normals. This allows the player to climb over gaps and complex geometry as if it was a smooth surface. I don't completely understand how they managed this, and I was wondering if someone who is knowledgeable about these things could explain how I could implement something like this in unity, I would appreciate any advice!
[1]: https://www.youtube.com/watch?v=EbNxBXaBol0raycastcontrollergeometryclimbingThu, 13 Aug 2020 21:46:37 GMTsupersulubuild not showing geometry
http://answers.unity.com/questions/1751473/build-not-showing-geometry.html
so i made a 2d game and everything is working fine in the editor but when i test the build it doesnt show some geometry. the gameobjects are there, the gameobject's physics and scripts work as planned but its invisible. how can i fix that?gameobjectbuildinvisiblegeometryFri, 17 Jul 2020 11:00:29 GMTunity_9P58GcCHwkNUOAHow do you do taxicab geometry in Unity?
http://answers.unity.com/questions/1748315/how-do-you-do-taxicab-geometry-in-unity.html
I have a ball and I want to move it around in 3d space (Specifically in SteamVR) using taxicab geometry.
I want to be able to move it along the prebuilt unity 3d grid lines. How would I go about doing this? Thanks in advance.vrgeometrySat, 04 Jul 2020 23:05:32 GMTYurtle_ButlerSmoothness of geometry look
http://answers.unity.com/questions/1743936/smoothness-of-geometry-look.html
Hi! I exported my flower model from Blender to Unity using FBX.
And the petals look not smooth with a lot of ugly stripes on it.
When I export the petals itself without flower they look alright.
And other elements like leaves look good and smooth.
Maybe it's something with rendering settings?
Please help.
![alt text][1]
[1]: /storage/temp/162424-screenshot-00359.jpgsmoothgeometryrendersettingsSat, 20 Jun 2020 12:42:40 GMTLiliaUlibkaHow to calculate a following camera with a restrain angle
http://answers.unity.com/questions/1735633/how-to-calculate-a-following-camera-with-a-restrai.html
Hello I have a math related problem I can't seem to resolve, I am trying to create a tps camera in unity in 3D similar to what we can see in Diablo3 or the latest Minecraft Dungeon, I never did that so I made a drawing to see how I can program that.
I have multiple constraints :
- My camera angle on the y axis should be 45°
- My camera angle on the x axis is a fixed variable
- The distance from my camera to the targeted object (character) is a fixed variable
Here's my drawing :
![alt text][1]
To tacle this problem I then need to find the position of the camera, I must use Thalès theorem
To find y I think I just need to multiply the cosinus of the angle (here 70°) by the hypotenuse which is the length of my fixed variable (here it's 3)
However to find x and z I think I first have to find the hypotenuse of those two light grey triangles, it's suppose to be the sinus of the angle (70) by the distance (3)
Now I can get x and z with those operations : x = sin(45) \* hypotenuse of the light grey triangle and z = cos(45) \* hypotenuse of the light grey triangle
Here is my code ![alt text][2]
The thing is I get something completely off center and I don't know why, I think my thinking is correct and my code as well
[1]: /storage/temp/160572-explanation.png
[2]: https://i.gyazo.com/c0b7a637d3dcfbb26b227e37da19fc23.pngcamerapositionmathgeometryThu, 28 May 2020 09:47:22 GMTMilleMillieImpossible non euclidean geometry help
http://answers.unity.com/questions/1732579/impossible-non-euclidean-geometry-help.html
I've found a way to make non euclidean geometry in Unity using stencil buffer portals.
The portals are not made with multiple cameras and there is no teleporting.
The portals only hide the overlapping geometry by separating the two using stencil buffer portals and layers.
I'm importing maps from an old game named Marathon.
Marathon maps need portals to function properly.
The Marathon map editor Weland can export maps as .obj model files, then normals and textures are added with blender.
All normals point inward and the map is separated into sectors.
The sectors and portals are separate game objects.
I found a way to use stencil buffer portals without having to edit or move sectors in the maps.
The game objects that occupy the same space are separated into two layers.
Layer 1 and layer 2 cannot collide with each other or interact.
Unity explains how to make layers.
https://docs.unity3d.com/Manual/Layers.html
https://docs.unity3d.com/Manual/LayerBasedCollision.html
The default layer connects and collides with both layer 1 and 2.
When the game object, player camera or enemy enters a portal, the portal checks if they cross the portal plane.
The portal changes the layer of the game object that crosses the portal plane to that layer the sector is.
Portal layer 1 changes player to layer 1.
Exiting the sector portal changes the game object player layer to default.
Unity explains how to change layers with script.
https://docs.unity3d.com/ScriptReference/GameObject-layer.html
There are four stencil buffer shaders, a read and write for layer 1 and a read and write for layer 2.
The read shader goes on the game object sector and the write shader goes on the portal game object.
Ronja explains how the stencil buffer works.
https://www.ronja-tutorials.com/2018/08/18/stencil-buffers.html
One read and write shader is set to ref 1 and the other read and write shader is ref 2.
Write shader ref 1 only renders read shader ref 1 from behind the portal.
This Youtube video explains how stencil buffer portals work.
https://www.youtube.com/watch?v=OBb4iUiXaRA
When the player camera crosses the portal plane and enters the sector, the read shader comparison is changed from equal to always.
When the player exits the sector portal the read shader on the sector is changed back to equal.
Unity explains the stencil buffer.
https://docs.unity3d.com/Manual/SL-Stencil.html
The portals have box colliders.
Ontriggerstay with crossing the portal does two things for the player, it changes the player game object layer and it changes the sectors read shader comp to always or equal.
To hide the enemy or player, when entering the portal they also have a read shader attached.
Anything that enters a portal is changed to that sectors layer and stencil reference value changed to that portals value.
The overlapping space stays separate and only what enters or exits the portals is changed.
Is there a better way to do this?layersgeometrystencilTue, 19 May 2020 19:12:58 GMTTharzzatHow would you go at making a spherical grid layout
http://answers.unity.com/questions/1732040/how-would-you-go-at-making-a-spherical-grid-layout.html
I want to create a grid in the shape of a sphere yet ,as little as I know, I can't figure where to even begin research this and how to implement it by code, The only grids i ever made were 2D square grids and never had any experience with 3D ones.
So the question is, How would you approach this and is it even possible (not hex grid but a square grid)?
Thanks in advance.gridgeometryMon, 18 May 2020 10:31:16 GMTsexysnizelFinding the intersection of vertical plane and scene mesh geometry
http://answers.unity.com/questions/1731511/finding-the-intersection-of-vertical-plane-and-sce.html
I need to find all the intersections of an upright plane with the main character's position and rotation. I currently have some code that works but is spewing out some strange values. In my code, I convert the 3-dimensional edges of all the meshes into two-dimensional equations in the form of Ax + By = C with bounds. I make an equation for the plane with the same form and calculate their intersection. If the intersection is within the edge's bounds, it calculates the percentage along the line from point 1 to point 2 and uses that the calculate a 3d position where the intersection takes place.
Here is my code:
public class Edge
{
public Vector3 p1;
public Vector3 p2;
public LineEquation Xequation;
public LineEquation Yequation;
public LineEquation Zequation;
public BoxRange Range;
public float Length;
public Edge(Vector3 p, Vector3 pp)
{
p1 = p;
p2 = pp;
float x = Mathf.Abs(p.x - pp.x);
float y = Mathf.Abs(p.y - pp.y);
float z = Mathf.Abs(p.z - pp.z);
Xequation = new LineEquation(new Vector2(p.y, p.z), new Vector2(pp.y, pp.z));
Yequation = new LineEquation(new Vector2(p.x, p.z), new Vector2(pp.x, pp.z));
Zequation = new LineEquation(new Vector2(p.x, p.y), new Vector2(pp.x, pp.y));
Range = new BoxRange(p, pp);
Length = (p - pp).sqrMagnitude;
}
}
public class LineEquation
{
public float A, B, C;
public LineEquation(float a, float b, float c)
{
A = a;
B = b;
C = c;
}
public LineEquation(Vector2 p1, Vector2 p2)
{
A = p2.y - p1.y;
B = p1.x - p2.x;
C = A * p1.x + B * p1.y;
}
public LineEquation(Vector2 p, float angle)
{
angle *= Mathf.Deg2Rad;
Vector2 p2 = new Vector2(p.x + Mathf.Sin(angle), p.y + Mathf.Cos(angle));
A = p2.y - p.y;
B = p.x - p2.x;
C = A * p.x + B * p.y;
}
}
public class BoxRange
{
public Vector3 lowerBound;
public Vector3 higherBound;
public BoxRange(Vector3 p1, Vector3 p2)
{
lowerBound = new Vector3(
Mathf.Min(p1.x, p2.x),
Mathf.Min(p1.y, p2.y),
Mathf.Min(p1.z, p2.z)
);
higherBound = new Vector3(
Mathf.Max(p1.x, p2.x),
Mathf.Max(p1.y, p2.y),
Mathf.Max(p1.z, p2.z)
);
}
}
public class PlaneCaster
{
public Edge[] edges;
public string layer { get; private set; }
public PlaneCaster(string tagLayer)
{
layer = tagLayer;
GameObject[] list = GameObject.FindGameObjectsWithTag(tagLayer);
List<Edge> buffer = new List<Edge>();
for (int i = 0; i < list.Length; i++)
{
Vector3 scale = list[i].transform.localScale;
Vector3 pos = list[i].transform.position;
Mesh mesh = list[i].GetComponent<MeshFilter>().sharedMesh;
Vector3[] vertices = mesh.vertices;
int[] triangles = mesh.triangles;
for (int j = 0; j < triangles.Length / 3; j++)
{
Edge edge1 = new Edge(Vector3.Scale(vertices[triangles[j * 3]], scale) + pos, Vector3.Scale(vertices[triangles[j * 3 + 1]], scale) + pos);
Edge edge2 = new Edge(Vector3.Scale(vertices[triangles[j * 3 + 1]], scale) + pos, Vector3.Scale(vertices[triangles[j * 3 + 2]], scale) + pos);
Edge edge3 = new Edge(Vector3.Scale(vertices[triangles[j * 3 + 2]], scale) + pos, Vector3.Scale(vertices[triangles[j * 3]], scale) + pos);
if (!CheckMatch(buffer, edge1)) buffer.Add(edge1);
if (!CheckMatch(buffer, edge2)) buffer.Add(edge2);
if (!CheckMatch(buffer, edge3)) buffer.Add(edge3);
}
}
edges = buffer.ToArray();
}
public void DrawPlaneRay(Vector3 pos, float rot)
{
rot *= Mathf.Deg2Rad;
LineEquation plane = new LineEquation(new Vector2(pos.x, pos.z), rot);
Debug.DrawRay(pos, new Vector3(Mathf.Sin(rot), 0f, Mathf.Cos(rot)), Color.green, 0.1f, false);
}
public void DrawDebug()
{
for (int i = 0; i < edges.Length; i++)
{
Debug.DrawLine(edges[i].p1, edges[i].p2, Color.red, 2f, false);
}
}
private bool CheckMatch(List<Edge> buff, Edge check)
{
for (int i = 0; i < buff.Count; i++)
{
if (
(buff[i].p1 == check.p1 && buff[i].p2 == check.p2) ||
(buff[i].p1 == check.p2 && buff[i].p2 == check.p1)
)
{
return true;
}
}
return false;
}
public List<Vector3> Cast(Vector3 pos, string axis, float rot)
{
List<Vector3> result = new List<Vector3>();
LineEquation plane;
if (axis == "x") plane = new LineEquation(new Vector2(pos.y, pos.z), rot);
else if (axis == "y") plane = new LineEquation(new Vector2(pos.x, pos.z), rot);
else if (axis == "z") plane = new LineEquation(new Vector2(pos.x, pos.y), rot);
else throw new Exception("Undefined Axis");
for (int i = 0; i < edges.Length; i++)
{
try
{
Vector2 reference;
if (axis == "x") reference = new Vector2(edges[i].p1.y, edges[i].p1.z);
else if (axis == "y") reference = new Vector2(edges[i].p1.x, edges[i].p1.z);
else if (axis == "z") reference = new Vector2(edges[i].p1.x, edges[i].p1.y);
else throw new Exception("Undefined Axis");
Vector2 intercept = GetIntercept(i, axis, plane);
if (
(axis == "x" && intercept.x > edges[i].Range.lowerBound.z && intercept.x < edges[i].Range.higherBound.z && intercept.y > edges[i].Range.lowerBound.y && intercept.y < edges[i].Range.higherBound.y) ||
(axis == "y" && intercept.x > edges[i].Range.lowerBound.x && intercept.x < edges[i].Range.higherBound.x && intercept.y > edges[i].Range.lowerBound.z && intercept.y < edges[i].Range.higherBound.z) ||
(axis == "z" && intercept.x > edges[i].Range.lowerBound.x && intercept.x < edges[i].Range.higherBound.x && intercept.y > edges[i].Range.lowerBound.y && intercept.y < edges[i].Range.higherBound.y)
)
{
float dist = (reference - intercept).sqrMagnitude;
float perc = dist / edges[i].Length;
result.Add((edges[i].p1 * (1f - perc)) + (edges[i].p2 * perc));
}
}
catch(Exception e)
{
}
}
return result;
}
public Vector2 GetIntercept(int index, string axis, LineEquation eq)
{
LineEquation line;
if (axis == "x") line = edges[index].Xequation;
else if (axis == "y") line = edges[index].Yequation;
else if (axis == "z") line = edges[index].Zequation;
else
{
throw new Exception("Axis is Incorrect");
}
float delta = line.A * eq.B - eq.A * line.B;
if (delta == 0)
throw new Exception("Lines are Paralell");
float x = (eq.B * line.C - line.B * eq.C) / delta;
float y = (line.A * eq.C - eq.A * line.C) / delta;
return new Vector2(x, y);
}
}
![alt text][1]
![alt text][2]
In the images above, the green line represents the plane's rotation, the red lines are all the calculated edges in the scene and the blue lines are lines going from the main player to the points of intersection. In theory, all of the blue lines should be parallel with the green line.
Any help in finding the problem with my code is appreciated.
[1]: /storage/temp/159675-capture.png
[2]: /storage/temp/159676-capture1.pngplanegeometrylinesintersectioncalculationsMon, 18 May 2020 06:06:08 GMTargentummanusbetamoving vertices dynamicly relative to other Object
http://answers.unity.com/questions/1730308/moving-vertices-dynamicly-relative-to-other-object.html
Hi, I have a cube, let's call it player, under that i have a procedurally generated plain, the palyer is going to move or rather float above and along that plain, I want to:
**A)** get the vertices around the cube that are in the radius of the player.
now i have achived that by looping through all vertices in that plain but that massivly cuts performance.
i want to be able to get the vertices that are in the radius with somthing like `physics.overlapsphere`
without having to loop through all the vertices, this obviusly doesn't work since overlapsphere ruturns a collider array and i want vertices which are a verctor3.
**B)** raise those vertices on the y axis relative to the players position (the closer the vertex is to the player the higher it is), now i have also gotten this to work but its not as nice and smooth as i want it to be, the vertices just lerp the Y axis to 3 if they are in the radius, and if not the don't move at all.
i want it to more dependent on more of where the player is rather than if its in the radius,
If you get what i mean.
Here is my current code:
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
[RequireComponent(typeof(MeshFilter))]
public class MeshGenerator : MonoBehaviour
{
//player's refrence
public Transform player;
//minimum distance for the vertex from the player to be affected and raised up
public float minDistance;
//limit for the vertices on the Y axis
public float meshOffset;
//mesh generation stuff
Mesh mesh;
Vector3[] vertices;
int[] triangles;
public int xSize = 20;
public int zSize = 20;
void Start()
{
mesh = new Mesh();
GetComponent<MeshFilter>().mesh = mesh;
CreateShape();
UpdateMesh();
}
void Update()
{
MoveVertices();
}
//Basically creating a plain at runtime to have a refrence to the vertices
void CreateShape()
{
vertices = new Vector3[(xSize + 1) * (zSize + 1)];
for (int i = 0, z = 0; z <= zSize; z++)
{
for (int x = 0; x <= xSize; x++)
{
vertices[i] = new Vector3(x, 0, z);
i++;
}
}
triangles = new int[xSize * zSize * 6];
int vert = 0;
int tris = 0;
for (int z = 0; z < zSize; z++)
{
for (int x = 0; x < xSize; x++)
{
triangles[tris + 0] = vert + 0;
triangles[tris + 1] = vert + xSize + 1;
triangles[tris + 2] = vert + 1;
triangles[tris + 3] = vert + 1;
triangles[tris + 4] = vert + xSize + 1;
triangles[tris + 5] = vert + xSize + 2;
vert++;
tris += 6;
}
vert++;
}
}
//updating the meshes vertices and triangles and recalculating lighting on the surface of it
void UpdateMesh()
{
mesh.Clear();
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.RecalculateNormals();
}
//Using the players refrence to get his pos and looping through the vertices array to find which vertices are in the redius of the player
// This is the part that i am not certain of
void MoveVertices()
{
for (int i = 0; i < vertices.Length; i++)
{
float distance = Mathf.Sqrt((player.position - vertices[i]).sqrMagnitude);
if (distance < minDistance)
{
vertices[i].y = Mathf.Lerp(vertices[i].y, meshOffset, Time.deltaTime * distance);
UpdateMesh();
}else
{
vertices[i].y = Mathf.Lerp(vertices[i].y, 0, Time.deltaTime * distance);
UpdateMesh();
}
}
}
private void OnDrawGizmos()
{
if (vertices == null)
return;
for (int i = 0; i < vertices.Length; i++)
{
Gizmos.DrawSphere(vertices[i], 0.1f);
Gizmos.color = Color.red;
}
}
}
for visualization, i am basically triying to mimic geometry wars meshs and how they react to objects positions and what's happening on the battle field
https://www.youtube.com/watch?v=x9eT6RWZ--0
As always, any help is appreciated
Thanks in advance!meshverticesvertexgeometryThu, 14 May 2020 02:56:47 GMTOnEd0tProBuilder Fill Hole Not Working
http://answers.unity.com/questions/1729538/probuilder-fill-hole-not-working.html
Hi,
I am new to using Probuilder. I am looking to create a ramp from a pentagon I sliced in half.
I tried Select Holes, then Fill Holes. Here are some of the the screenshots of the geometry I am trying to make:![alt text][1]![alt text][2]
[1]: /storage/temp/159263-1.png
[2]: /storage/temp/159264-2.png3d3d modelsgeometryfillTue, 12 May 2020 07:43:35 GMTdecoy98