New answers tagged

0

I don't think there's an efficient way of solving the problem exactly, but here's how I'd try to tackle it. First, I'd use bounding volumes around each object, instead of the objects themselves. Each object can be approximated by the union of more than one bounding volume, though. The simplest solution would be to compute a single bounding volume that ...


0

There are two ways to address this question that I can see. First, if you simply want to find a way to steer, then you just need to implement pathfinding (I find this quite helpful). That would be the end of that (and is the correct practical answer to this question), but I think you are more curious about a mathematical solution to your problem. To address ...


1

When you have 2d sprites in a 3d environment, they work like two-dimensional planes. Think of them as cardboard-cutouts which are moving through the world. When you want to rotate these cardboard cutouts to always face the camera, then the search term you are looking for is "Billboarding". It can be implemented by attaching this MonoBehaviour to it: using ...


1

I would recommend you to place the 2d sprite not in the game world but instead place it on a UI canvas with "Screen Space - Overlay" mode. You can convert the game-world position of a GameObject to screen-coordinates using Camera.WorldToScreenPoint. Then you need to convert the screen coordinates to canvas coordinates and place your sprite there. Code ...


0

You could add a child to the barrel and add a script to the child that will set one of its rotation axis to the starting value which means one of its rotation axis eg. forward will always stay the same and it could act as an indicator of the forward direction of the barrel since it will be moving and rotating on other two axis the same as the barrel. Your ...


-2

Thanks to some of the above comments I did find my answer. I forgot to post my answer, but I thought I would go ahead and add it for anyone who is curious. I recommend looking at the original algorithm and also the above mentioned link to explain the general idea. I chose to use three-dimensional Perlin Noise (by Ken Perlin originally). This is a smooth ...


3

There are two common ways to animate something. One of them is what you described: morphs or per-vertex animation. You have number of different models representing each frame in your animation, and you interpolate the position of the vertices individually between the previous frame and the next to achieve smooth animation. This technique is usually applied ...


0

I wasn't sure if there was a name for the technique, but I was corrected, (Thank you, DMGregory) and a common name for the technique would be having a "specular mask", where a colour channel of a texture "masks" or controls the intensity of the specular reflection. This is demonstrated below in this code which is actually an excerpt from the code of the ...


1

First, we pick out a unit vector describing our vertical axis (or, more generally, the axis on which the constant acceleration is being applied): Vector3 vertical = Vector3.up; // If wind introduces diagonal acceleration, // include it here too and normalize. Then we isolate the perpendicular/horizontal component of the ...


0

There is never an N-gon in any model for a game. All graphics cards use triangles. N-gons are a software construct in 3D apps. When you model for games you should always use triangles or get rid of n-gons. I use Cinema4d and it has some good tools for that. Blender does also. If you do not triangulate your model, the end-user game engine or importer will ...


0

If we consider a 'classic' top-down view minimap, we can consider that the minimap is at the plane of z = 0. To help show the 3d dimension, you could add an additional plane at x = 0 and another at y = 0, and project a line between the object and the 3 planes. Of course, you'll have to modify the angle of view of the 3d map with regard to the current ...


0

You can use velocity for this purpose. Also you can improvise your code if you have to have inputs through arrow keys and WASD. Rigidbody _rb; float _speed = 30f; void Start () { _rb = character.GetComponent<Rigidbody> (); } void Update () { float horizontal = Input.GetAxis ("Horizontal"); float vertical = Input.GetAxis ("Vertical"); ...


0

You are most of the way there already. The problem is, OnTriggerEnter only happens once. Quaternion.Lerp changes the value over time, at the speed specified by the timestep. Since it is only being called once, it will only move the rotation one step. In this case, .1f * Time.deltaTime is your step. This is a very small number. It needs to move that small of ...


-1

How about drawing a quad strip for each row in your grid of quads? I guess it depends on how you're representing your data. One way could be to have a 2D array of 3D coordinates for the grid's vertices. To start, the Y component can be zero and then you can assign random Y values while maintaining the X and Z values intact. Then you would draw a ...


1

I understood by myself how to retrieve the frame rendered and now I have this method : void Renderer::getVideoStream(){ glReadBuffer(GL_BACK); int width = m_window->width(); int height = m_window->height(); vector< unsigned char > buf( width * height * 3 ); glPixelStorei( GL_PACK_ALIGNMENT, 1 ); glReadPixels( 0, 0, ...


3

Alternatively - to provide an easier-to-implement and more efficient solution - one can check the mesh's Euler-Poincaré characteristic. Given the number of vertices V, number of faces F and number of edges E. A triangle mesh is a closed 2-manifold, if and only if V + F - E = 2. If you store your mesh as a list of vertices and indices, V and F can ...



Top 50 recent answers are included