Questions in topic: "mathf.cos"
http://answers.unity.com/questions/topics/single/6637.html
The latest questions for the topic "mathf.cos"Field of view cone positioning?
http://answers.unity.com/questions/1631611/field-of-view-cone-positioning.html
I have a field of view cone for my player to search for ledges around him when climbing.
I used this (very, very good) tutorial (https://www.youtube.com/watch?v=rQG9aUWarwE&t=565s) to get the field of view cone. I have managed to alter the cone so that instead of facing forward, it faces the direction that my analogue stick is pointing.
My problem is that while the cone points the way I want it to point, it does not rotates with my player. It rotate around one fixed axis no matter the direction my player is facing.![alt text][1]
[1]: /storage/temp/138180-cone.png
In the picture, the view cone is always perpendicular to the X-Axis (world-space). I want it to move this cone to rotate with the player.
public Vector3 DirFromAngle(float angleInDegrees, bool angleIsGlobal)
{
if(!angleIsGlobal)
{
angleInDegrees += (viewDir + 90);
}
Vector3 newValue = new Vector3(0, Mathf.Sin(angleInDegrees * Mathf.Deg2Rad), Mathf.Cos(angleInDegrees * Mathf.Deg2Rad));
return newValue;
}
This is the code that handles the cone's position. The viewDir is the analogue's position in degrees.
Thank you for any help.field of viewmathf.sinmathf.cosTue, 14 May 2019 13:30:35 GMTFRStudios1998The knockback function I made is pushing me to the left
http://answers.unity.com/questions/1590272/the-knockback-function-i-made-is-pushing-me-to-the.html
this is my knockback function the takes in an angle, force, and hitstun. The rigidbody's velocity is set to zero before the force is applied, sin for y and cos for x and then multiplied by force. Y is multiplied by the gravity scale in the rigidbody. The problem is that it pushed the player to the left, for example if the angle is 90, the player should be sent straight up, but its pushed upwards and to the left. Any help is appreciated.
private void KnockBack(float ang, float force, float stun)
{
rb.velocity = new Vector2(0,0);
rb.AddForce(new Vector2((Mathf.Cos(ang) * Mathf.PI) / 18 * force * 100, (Mathf.Sin(ang) * Mathf.PI) / 18 * force * 100 * 5));
hitStun = stun;
state = "stunned";
}rigidbody2drigidbody.addforceknockbackmathf.sinmathf.cosTue, 15 Jan 2019 05:02:00 GMTspirachi77How can I get a point position in circle line
http://answers.unity.com/questions/1545128/how-can-i-get-a-point-position-in-circle-line.html
![alt text][1]
[1]: /storage/temp/123196-untitled-1-recovered.png
Positions on the three-dimensional plane are 45 degrees apart on the circle. The positions corresponding to the angles are indicated on the left. What happens to the position of a random angle coming from the central point of the circle in the 3-dimensional plane on the corresponding circle line? As an example, I try to find the position between two specific positions of a random angle that emerges from the 45 degree circular section of the circle I have specified in blue.mathmathsmathf.sinmathf.cosWed, 22 Aug 2018 17:42:49 GMTmryasaremirtriangulate angles between three objects.
http://answers.unity.com/questions/1446835/triangulate-angles-between-three-objects.html
Hi, i am trying to calculate the angles between a ball and two goal post. Once I have that, I am will cut the angle in half and have the goalie move into position similar to how real goalies cut the angle. However, I am getting results that arent even close. I have used actual Cos eqautions based on the length of each side.
distancetoBall = Vector3.Distance(transform.position, gameBall.transform.position);
distLeftPost = Vector3.Distance(gameBall.transform.position, leftPost.transform.position);
distRightPost = Vector3.Distance(gameBall.transform.position, rightPost.transform.position);
//dlf is B, dbp is c, drp is a
angBall = (Mathf.Pow(distLeftPost, 2) + Mathf.Pow(distBetweenPosts, 2) - Mathf.Pow(distRightPost, 2)) / (2 * distLeftPost * distBetweenPosts);
Debug.Log(Mathf.Cos(angBall) * Mathf.Rad2Deg);anglesmathf.cosTue, 26 Dec 2017 16:28:54 GMTrevolution5Unit Circle Coordinates
http://answers.unity.com/questions/1107840/unit-circle-coordinates.html
Hello, I've just recently learned the unit circle in school and to help myself further understand it, I thought I'd add it to my movement script so that no matter what direction you're moving, you're going the same speed. There are probably other ways to do this but this was just for a learning experience. Here is my code:
Vector2 desiredInput = Vector2.zero;
desiredInput.x = Mathf.Cos ( Mathf.Atan2 ( rawInput.y, rawInput.x ) * Mathf.Rad2Deg );
desiredInput.y = Mathf.Sin ( Mathf.Atan2 ( rawInput.y, rawInput.x ) * Mathf.Rad2Deg );
float lerpSpeedX = rawInput.x != 0 ? moveSpeedLerpSens : moveSpeedLerpGrav;
float lerpSpeedY = rawInput.y != 0 ? moveSpeedLerpSens : moveSpeedLerpGrav;
input.x = Mathf.Lerp ( input.x, desiredInput.x, Time.deltaTime * lerpSpeedX );
input.y = Mathf.Lerp ( input.y, desiredInput.y, Time.deltaTime * lerpSpeedY );
What about this is wrong? Any help and/or tips would be appreciated!mathfmathf.sinmathf.cosSat, 05 Dec 2015 18:04:55 GMTndrummer31Cos creates problems with addforce
http://answers.unity.com/questions/1041900/cos-creates-problems-with-addforce.html
Hello,
So I am making a 3d game on android and using the accelerometer to move. When I play the game on the phone, it is very hard to control my character because I have to hold my android at 90 degrees for no force. I tried the following code so that the user can have a comfortable angle of holding and playing while sitting. But when i use Mathf.Cos/System.Math.Cos for creating and adding force, my camera goes to some weird location when i tilt my phone parallel to the ground. If i use some other value for the variable, it doesn't create the problem. I have been trying for hours to figure this out and have had no luck. Is it possible to do so in another way? Could it be a possible bug?
I'm using Unity 5.1.2f1 Express Edition.
Thanks.
I tried with the following code:
float moveVertical = Mathf.Cos ( Mathf.Acos((float)-Input.acceleration.z) - 1.3f );
float moveHorizontal = Input.acceleration.x;
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
gameObject.AddForce (movement * speed);addforcemathfcoscosinemathf.cosSat, 05 Sep 2015 12:20:43 GMTsarthaks95Using sin and cos to decompose a vector
http://answers.unity.com/questions/964041/using-sin-and-cos-to-decompose-a-vector.html
I want to decompose a vector, being the rotation.y and a float force, and assign to x and z floats. So I made this code:
transform.Rotate(0, Input.GetAxis("Horizontal"), 0);
float rot = transform.rotation.y;
float x = force * Mathf.Cos(rot)* Input.GetAxis("Vertical") * Time.deltaTime;
float z = force * Mathf.Sin(rot)* Input.GetAxis("Vertical") * Time.deltaTime;
rigidbody.AddForce(new Vector3(x,0,z));
I see some problems that are: rotation varies between 0 and 1 instead of 0 and 360 and Cos and Sin methods return in radian. I can not solve that problem. Can someone help?
The result that I want to reach is make a object go to where is facing. Decomposing the force will move the object in x axis and z axis.mathf.sinsincoscosinemathf.cosMon, 11 May 2015 11:50:45 GMTMateusSarmentohow to properly use mathf cosinus?
http://answers.unity.com/questions/553192/how-to-properly-use-mathf-cosinus.html
what ever I do I get totally wrong resault
http://www.mathsisfun.com/geometry/unit-circle.html
http://docs.unity3d.com/Documentation/ScriptReference/Mathf.Cos.html
- cos 0.5f should be 60°
- cos 0 should be 90°
but they aren't:
Debug.Log(Mathf.Cos(0.5f) ); // 50.28178
Debug.Log(Mathf.Cos(0f) ); // 1
Debug.Log(Mathf.Cos(0.5f) * Mathf.Deg2Rad); // 0.01745329
Debug.Log(Mathf.Cos(0.5f) * Mathf.Rad2Deg); // 57.29578
so what am I doing wrong?noobmathf.cosThu, 10 Oct 2013 17:23:22 GMTsdgdHow to have an object be plotted with an angle and altitude around an object
http://answers.unity.com/questions/416584/how-to-have-an-object-be-plotted-with-an-angle-and.html
I have made a simple script to test the feasibility of this idea, but it doesnt work.
#pragma strict
var originX = 0;
var originY = 0;
var altitude = 100;
var angle = 45;
var relativeX = 0;
var relativeY = 0;
function Start () {
}
function Update () {
if (angle < 90 && angle > 1)
{
relativeX = Mathf.Sin(angle) * altitude;
relativeY = Mathf.Cos(angle) * altitude;
transform.position = Vector3(relativeX + originX,0,relativeY + originY);
}
else
{
angle = 0;
}
angle = angle + 0;
}
I realize this wont work with angles outside 1 through 90, this was just a test, hence the check
the script will plot the object around the other, but it appears that every angle increment it adds 60°, and will somehow happily go above 90°, and well above 360°. the object also randomly disappears which i assume has something to do with bad scripting.javascriptanglemathf.sinradialmathf.cosThu, 14 Mar 2013 06:11:31 GMTcineboxandrew