rotate a particle system in world scope unity - unity3d

I created this particle (show in gif file) ,by rotate particle I want to new particles spawn in new direction and rotation, but previous stay in their initial rotate and direction, and this is my particle settings:

You should set Simulation Space to Local. World space particles aren't affected by Transform's rotation after they are emitted.

In the particle system's Renderer settings, set the render mode to Mesh. Pick the Quad, or your custom mesh, and then set its render alignment to velocity.
Set the start speed to a non-zero value, such that the particle will now emit towards your transform rotation direction. (If you want to keep the particle stationary, but follows the rotation of your transform, set the particle speed to a extremely small value, like 0.0001)
Make sure the simulation space is set to "World"
With this, the particle rotation should now align with the velocity of your particle. To make the particle faces the camera, enable "3D start rotation" and adjust the rotation angles until it matches your desired orientation.
And now, you can change your particle system transform's rotation to change the orientation of your particle. Existing particles will stay at its original rotation, while newly emitted particles will orient towards the transform rotation.

Related

How would I keep the rotation of the look of the object but make the rotation 0 Unity

How would I be able to have Wheel look the same but make the rotation 0.
As already commented you can rotate the mesh in 3D modeling software.
A faster way would be to parent the GameObject that represents the wheel under another GameObject, which will be acting as a pivot then. Just position it at the exact position of the wheel GameObject, but with a the desired rotation.

How to smoothly move a node in an ARkit Scene View based off device motion?

Swift beginner struggling with moving a scene node in ARkit in response to the device motion.
What I want to achieve is: First detect the floor plane, then place a sphere on the floor. From that point onwards depending on the movement of the device, I want to move the sphere along its x and z axis to move it around the floor of the room. (The sphere once created needs to be in the center of the device screen and locked to that view)
So far I can detect the floor and place a node no problem. I can use device motion to obtain the device attitude (pitch, roll and yaw) but how to translate these values into meaningful x, y, z positions that I can update my node with?
Are there any formulas or methods that are used to calculate such information or is this the wrong approach? I would appreciate a link to some info or an explanation of how to go about this. Also I am unsure how to ensure the node would be always at the center of the device screen.
so, as far as I understood you want to have a following workflow:
Step 1. You create a sphere on a plane (which is already done)
Step 2. Move the sphere with respect to the camera's horizontal plane (i.e. along its x and z axis to move it around the floor of the room depending on the movement of the device)
Assuming that the Step 1 is done, what you can do:
Get the position of the camera and the sphere
This should be first called within the function that is invoked after sphere creation (be it a tapGestureRecognizer(), touchesBegan(), etc.).
You can do it by calling position property of SCNNode for sphere and for camera position and/or orientation by calling sceneView.session.currentFrame's .camera.transform which contains all necessary parameters about current position of the camera
Move the sphere as camera moves
Having the sphere position on the Scene and the transformation matrix of the camera, you can find the distance relation between them. Here you can find a good explanation of how exactly you can do it
After you get those things you should implement a proper logic within renderer(_:didUpdate:for:) to obtain continuous lock of the ball with respect to the camera position
If you are interested about the math behind it, you can kick off by reading more about transformation matrices which is a big part of Image Processing and many other areas
Hope that this will help!

cylinder simulation on top of each other in unreal engine 4

I created 2 cylinders and put one on top of the other. Then I clicked to simulate physics and on each cylinder I added the following image blueprint, added a 50-point rotation on the z axis of each cylinder in opposite directions.
It turns out that in the simulation, when I perform, the cylinders rotate in one direction and move on the ground in the other direction. If it turns clockwise it moves left, and vice versa, and should be the other way around.
Can anyone help me solve this? It's for both cylinders to work together and I see how their simulation is accelerating with a constant rotation, but that's not what happens
If you want to simulate physics you should be applying forces to the cylinders using Add Torque in Radians or Add Torque in Degrees rather than modifying the rotation directly.
Alternatively, if you want to precisely control the cylinders, do not simulate physics. Instead, disable Simulate Physics and animate the rotation and position of the cylinders directly as you are.

How do I apply rotations to parent child using Rigidbody?

I have a finger object. It is just three cubes representing the finger parts.
The 2nd cube is the child of the 1st one. And the 3rd cube is the child of the 2nd one.
This is the heirarchy: Cube1 -> Cube2 -> Cube3
My goal is to apply a rotation angle to the first cube and let the other cubes do the same locally.
Example: Apply 30 degrees Z rotation to the first cube, 30 degrees Z rotation to the 2nd cube, and also the 3rd one.
This will make a finger that look like this:
(Forgive me if it doesn't look like a finger)
In every Update() frame, I will change the angle (it's just one number) and it will rotate every cube for me.
My question is:
How do I make all these cubes collide properly with other objects?
I tried putting the Rigidbody on all of them and set isKinematic=false because I want to transform them myself. But I still cannot use transform.rotation to update my rotation because it will miss the collision with a ball very easily (especially the tip of the finger because it moves faster than other parts). Continuous detection doesn't help.
So I tried using rigidbody.MoveRotation() and rigidbody.MovePosition() instead, which is a pain because they need absolute values. They worked but the animation is so jumpy when I change the angle quickly.
I'm guessing that the animation is jumpy because there are many Rigidbodies or because the physics engine cannot interpolate the position of each box properly when I use MoveRotation() and MovePosition().
I need to use MovePosition() also because when I use only child.MoveRotation(transform.parent.rotation * originalChildLocalRotation * Quaternion.Euler(0, 0, angle)), the position doesn't move relative to the parent. So I have to compute child.MovePosition(parent.TransformPoint(originalLocalPositionOfTheChild)) every frame too.

How to change gravity direction on Sprite Kit?

I am using Sprite Kit in Xcode and I was wondering how to change gravity direction.As default gravity direction to "X" you can imagine on below axes graphic.What about if I would like to change to "Y".
My goal is giving to object the falling effect.Its like falling from hight point and touching the ground than getting respond with physics!
(Could be dices on board game)
//Default gravity direction is X
SKSpriteNode *myNode =[SKSpriteNode spriteNodeWithImageNamed:#"ball"];
myNode.physicsBody=[SKPhysicsBody bodyWithCircleOfRadius:self.frame.size.width/2];
[self addChild: myNode];
Thanks in advance!
You can apply a vector to the Physics World of your scene using this code
self.physicsWorld.gravity=CGVectorMake(0,-10);
In SpriteKit, X and Y are the default coordinates that you see on the screen, and the Z coordinate is the order in which the objects are positioned (the zPosition). Since SpriteKit uses a 2D game engine, you do not have a third dimension, Z, to utilize. You can change the gravity between Y and X (Top/Bottom and Left/Right of screen respectively), but not between the Z coordinate. If you want to recreate a "dice falling" effect, I would recommend you create a Sprite called Dice scaled to a large amount, and once you add it to the scene you scale it down in x amounts of seconds.
[self runAction:[SKAction scaleBy:negativeFloatHere duration:3]];
This will make the dice appear to be falling, and you might want to add some spinning animations for it if you with. If you want to use the 3D engine, go try out Metal or SceneKit