1
vote
1answer
55 views

Usage of math.Atan2 in a 3D coordinate system with Unity

I have a simple question on usage of math.Atan2 function with Unity in a 3D environment. I found this code on Unity's documentation for Math.Atan2. I changed it a bit to fit my needs. Vector3 ...
0
votes
1answer
79 views

Gun Bobbing Algorithm Math Explanation

I stumbled across this really neat algorithm which I don't fully understand. It simulates a camera's bobbing effect commonly witnessed in first person shooters while running/walking. I'm mainly unsure ...
0
votes
2answers
163 views

How do I create a knockback-movement?

I am a web developer new to game development, and with limited math knowledge. I am writing a character movement controller in Unity. The game has an isometric Diablo-like camera. The character moves ...
0
votes
1answer
113 views

Projecting a light onto a quad

I need to project the light onto the quad and use its value for translating the vertices. I'm currently having 6 vertices, two quads, The points are A X C B Y D Point X, Y are coming from two ...
0
votes
0answers
55 views

3D model editor manipulators

I'm trying to make my own 3D model editor to better learn 3D programming. I have my translate manipulators and I'm trying to calculate the Vector2 that the mouse would have to move in order to move an ...
2
votes
2answers
371 views

Intelligently move aircraft using curves

I am trying to code a script to move an aircraft entity from point A to point B and at some point in the middle of moving have the aircraft forward vector face Point C (to fire a missile at an enemy ...
0
votes
1answer
41 views

What is the actual formula to find the vertices of an animation frame in using a BVH file?

I've read this tutorial and tried many formulas to build the skeleton. I am able to build it without the rotations, but those break everything. This, for example, is a simplified code for one of my ...
2
votes
1answer
295 views

C# - Separating Overlapping Rectangles

I'm trying to separate an arbitrary number of randomly sized rectangles, while still keeping them snapped to the grid, and somewhat packed together nicely. The goal is to start with something like ...
0
votes
1answer
50 views

Getting the position of a directional light w.r.t. a moving object.

I have a forward vector of my object, which is a bike, and its position, and I have a directional light direction. I would like to know where the light is with regards to the bike ...
-1
votes
1answer
126 views

lerp z rotation towards mousepointer

I am trying to get transform.rotation.z to chase the mouse pointer at a rotation speed. But I get a very weird results and can't figure out what I am doing wrong. var mp = Input.mousePosition; ...
-2
votes
1answer
155 views

Lerp speed or lerp time [closed]

Am I right about the fact that lerping can be done over a set period of time or at a speed which will continue until the target is reached? How are the formulas for the two? Is it something like ...
2
votes
1answer
294 views

Project collision shapes to plane for 2.5D collision detection

I am working on a top down 2.5D game. In the game anything that overlaps on the screen should be 'colliding' with each other regardless of whether they are on the same plane in the 3D world. This is ...
7
votes
3answers
372 views

Slerping rotation mirrors

I rotate my game character to watch at the target using the following code: transform.rotation = Quaternion.Slerp(startQuaternion, lookQuaternion, turningNormalizer*turningSpeed/10f) ...
-1
votes
2answers
121 views

Velocity deacceleration working incorrectly

Basicly, I've tried to code velocity into my game, which works sort of. The deaccelaration works sort of, but not correctly. The problem is, that the positive values, decreases just fine and dandy to ...
0
votes
0answers
108 views

Follow sinus with absolute value

I would like to make an arm follow the sinus of the ball. When I add an absolute value to the ball (on the y axis) to get a more realistic bounce, the ball is going 2 times faster. How could I ask ...
2
votes
1answer
112 views

Getting half plane direction relative from cam position

Im implementing certain Camera movements in my turn based games. I'm able to place and rotate the camera between two units that attack each other. However it will always move to the same "side". Which ...
0
votes
3answers
161 views

Keeping raycast on the same level

I want my raycast to end at certain height(red line). But as the game is 3D and the camera rotates I can't use a fixed magnitude. What I thought was a stroke of genius, I figured I'd project the ...
2
votes
1answer
120 views

Rotation independent rotation

I came up with some cube rotating, but I could not make it smooth and easy to use because as the cube turned - the keys that handle the turning changed their purpose. Link to demo. The demo rotation ...
0
votes
0answers
57 views

Going from point a to b through a curve using “gravity” [duplicate]

I have enemies and when they die they spawn an energy ball with a given velocity. I want to move this ball to the player using "gravity" to create a curved path. I have a version of the function but ...
3
votes
2answers
474 views

Discover x,y coordinates given set arc distance and rotation

I have a turn-based car simulation. My vehicles have a maximum speed they can travel in a round, as well as a maximum amount they can change their heading over the course of a round. Say, 20 meters ...
3
votes
3answers
1k views

Getting correct angles between Vector3s

I'm working on a project where you can draw lines between points. You select one point and drag the mouse onto another point and a line is drawn between them. The line itself is a 3d object which is ...
4
votes
1answer
207 views

How to transform mesh components?

I am attempting to transform the components of a mesh directly using a 4x4 matrix. This is working for the vertex positions, but it is not working for the normals (and probably not the tangents ...
1
vote
1answer
520 views

How to get a point to the left/right of a vector

I have a position vector of a point in space and a quaternion for it's rotation. What i'm trying to calculate is a point too the left and a point to the right. I have the position and ...
8
votes
1answer
2k views

Why doesn't Unity's OnCollisionEnter give me surface normals, and what's the most reliable way to get them?

Unity's on collision event gives you a Collision object that gives you some information about the collision that happened (including a list of ContactPoints with hit normals). But what you don't get ...
3
votes
1answer
391 views

How do I find the largest circle possible in a square of pixels using Unity?

As I am using Unity, I can easily grab a square of pixels of any length. However, I want to find the largest circle possible within that square of pixels. So for instance, if I had a 40 x 40 square ...