Rotate an object with RotateAround to a specific value - unity3d

I'm new in unity engine and try to rotate an object to specific value, but could not find any answer!
For example, I have an Euler angles (0,0,48) and my object in (0,0,340). I want give (0,0,48) values to my object with RotateAround() function to my object. Because it should rotate around of a point!

Unless you have a point in space you wish to rotate through, use Transform.Rotate(). that should be more than enough for you to rotate an object by (0,0,48) like you said.

Related

Get result of add impulse if object was not moved

So, lets say my character has the ability to push "movable" objects. This is alredy implemented and working as desired.
But I want to make the characher be pushed back if he tries to push an object that is hitting a wall or an immovable object, is there a way to see if my add impulse had any effect?
Or a best way to do is some ray casts on the movable object boundaries to see if is touching any other thing?
For characters you can use Launch Character. It's like adding velocity giving a specific direction. Add Impulse is intended to be used with Objects that simulate physics.
Just Launch the Character to a direction opposite the direction it's touching. You can use Dot Product between Character Velocity and the Object Face (forward).

How can find Center of circle to Unity?

I have circle, and I'm trying to find center and convert to Vector2.
For example:
circleLocation : new Rect( Screen.width/10, Screen.height/2.75, Screen.width/3,Screen.width/3);
centerofcirle:New Vector2(circleLocation.width/3, circleLocation.height/3);
But this example's not correct, the circle is not turn center. What is this formula? How can find correct center of cirle and how to convert Vector2?
Reading between the lines here, I wonder if issue has nothing to do with your code here, but with the rotation point of your steering wheel object, which isn't where you want it to be.
A common technique to change the rotation point of a game object is to make that object the child of another game object in the Unity Editor. Then set the position of the child object as you wish relative to the position of the parent object. Now, rotate the parent object. The child object will automatically rotate around the parent object's position, since it's transform (including position/rotation) is relative to it's parent's.
You seem to be defining your circle using a Rect so just use the Rect.center property:
circleLocation.center;

iTween consider up vector of transforms

I'm using iTween.MoveTo and for the "path" argument, I give an array of transforms. Though the transforms are placed on a sphere. The object moves very nicely over the path, but it stays oriented upwards instead of properly oriented on the sphere.
I tried using the "lookat" argument and giving that the center of my sphere and that works (after tweaking my character a bit that if it looks at the center it's actually standing on it) but then he won't look ahead on the path.
So, is there any way I can make iTween to take the up vector of the transforms into account?
Thanks!
One way to do this is to disable the "lookat" and turn a flag on when the iTween is happening ( I suggest a Coroutine that uses WaitForSeconds for the duration of the tween ).
Then, on your Update/FixedUpdate routine, you can use the following code:
outSideObjectTransform.forward = outSideObjectTransform.position - lookTarget.position;
This will make the outsideObject have it's forward axis direction going away from the center object. The same can be said for any of the axis.
Also, if you want the exact opposite ( that the object looks towards it's "look target") , just replace the subtraction of the two Vectors with an addition.
I hope this helps.

2d Look at Function

I am creating a 2d sidescroller game. I have a point in space (where the mouse is) and I need the weapon to look and "follow" that point.
Does anyone know where to begin?
wikihow: How to Find the Angle Between Two Vectors
After you have the angle, you can appropriately rotate the thing to be rotated.
I am not sure if javascript also has an atan2(x,y) function, which could be used to get the angle.

animating object along a path in unity 3d

I need to animate an object along a path. I am doing so by creating an animation like:.
This works great but since my terrain is not flat it will be nice if I don't have to deal with the y component. In other words I want to move an object along the x-axis and z-axis and if there is a small slope increase then increase the object y position. same thing if there is a downward slope. Or maybe I have to create a script where it checks to see if the object is colliding with the terrain. if not then decrease its y position. I don't know if this will work meanwhile animating an object though.
I think the easiest way I can think of to solve this is for you to make the object a rigid body and use collision (probably a mesh or capsule collider if its a player character) to get it to sit on the floor.