This is my css
.my-node:hover
{
-fx-translate-z:-50;
}
and I have perspective camera for the scence
scene.setCamera(new PerspectiveCamera());
Now when I move my cursor on the node with applied class it starts jumping forward and backward.
What am I doing wrong here?
What do you want to achieve?
If node changes z coordinates it will move back and forth except situation then node is located exactly in the place where z-axis is started.
Related
I am trying to use an AVAudioEnvironmentNode() with AVAudioEngine and ARKit.
I am not using ARSCNView or any of the other ARViews, this is just a plain ARSession.
I have a sound source -> AVAudioEnvironmentNode -> AVAudioEngine.mainOut.
I understand how set the position of the sound source. I am trying to figure out how to move the audioListener. Because I want to walk around the sound source in space.
The Apple Documentation says that to update the node's listener position you use.
AVAudioEnvironmentNode.listenerPosition = AVAudio3DPoint(newX, newY, newZ)
When I pass the ARCamera's forward and up to the node, that seems to change fine. However when I trying to change the position, I do not hear anything, and when I print a debug of listenerPosition, the output stays at zero origin, even those the camera's position is moving.
Is there something I have to do to make the AVAudioEnvironmentNode movable to take a new position?
Thanks.
My main character moves by touching and holding him and then moving your finger left or right to move the character. To do this I just simply update the node's x position (walks left and right on a flat surface) in touchesMoved() with the x position of the touch location, and apply an animation depending on the direction he's moving.
I want to kind of take this to the next level and accomplish the same effect, but using physics, so that when I'm done moving him and release my finger, he may slide a little bit in the direction he was moving given the speed I was moving him at, if that makes sense. Does anyone know how I can accomplish this effect?
Would I have to do as I'm currently doing and update the position as it moves, but also apply a force/impulse at the same time? Kind of confused on how to approach this
Moving the physics body via force, impulse, or velocity will automatically update the player position.
So you will have to play around with the correct way to accomplish your goal. But based on this, what I would suggest is replace your .position code with .physicsBody!.velocity code in your touchesMoved. Then, on your touchesEnded, you can apply a bit of an impulse to give the player that little bit of an "on ice" effect to keep them going a tad.
You will need to experiment with how much velocity you want to get the character to move at the correct speed, and then you will need to play with the impulse figures as well to get it just right.
This could get a bit tricky though, in touchesMoved... because at some point you will want to reset the velocity to 0 (so they stop moving when your finger stops).
To do that, you will need to to use the .previousLocation from your touch object, and compare the distance of X moved. if the distance X moved is >0 (or some deadzone threshold) then apply the velocity; if the deltaX is 0, then set the velocity to 0.
This may actually be more complicated than just using .position to move the character, then having the character slide a bit with physics on touchesEnded.
You will have to play with it to get it right.
Currently I am doing a project of shell toss in Unity. The shell is made in Blender and imported in Unity. I attached a single box collider to the shell.
Now when I apply the random force to the shell to flip it, it sometimes rests in the vertical up position when either a result of heads (face-up) or tails (face-down) should have occurred.
I have tried changing the axis, increasing the gravity. But none of these solutions worked.
What I have done for now is when the shell is in a resting position after it lands, I rotate the shell 90 degrees - but this is not a great solution, since it is slow and takes time to check whether the shell has come to rest or not.
I am looking for the better idea so that the shell should only rests in a heads or tails state.
If you use a box collider for your shells, you are going to end up in this problematic situation where the flipped shell sometimes ends up sitting sideways, instead of face-up or face-down.
In this situation, I would recommend making use of Capsule Colliders, which are cylindrical colliders with a rounded top and bottom. If a capsule collider lands on either end, it'll fall over sideways:
However, one capsule collider isn't enough - otherwise, the shell will start rolling around after it falls over. I suggest 2 or 3, oriented in a cross such that their tips correspond to the sides of the shell:
Now, if the shell lands on any of its sides, it will topple over onto one of the faces of the cross - either face-up, or face-down. To add capsule colliders to your GameObjects, just click on Add Component, and select Physics > Capsule Collider. Then modify the properties to get them into the desired positions:
The Direction you choose should probably be X-Axis and Z-Axis. Once you have the correct orientation, change the Center value to move the colliders to the right positions to make a cross through the shell. Then, alter the Radius of the colliders to affect the thickness of the cross, and the Height so their tips line up with the edges of the shell.
Hope this helps! Let me know if you have any questions.
I am doing a small game project named "puzzle game". Every piece of the puzzle should can be both moved and rotated. Whether I move the piece or roate the piece, I just do the same mouseEvent that move my mouse.
The differrence is that:
1) When the mousePoint is at the centre of piece , I will do pressMove;
2) When the mousePoint is at the edge of piece, if I move mouse, the piece will rotate according to the caculated angle.
But now, I don't exactly know how I do this.THANK YOU FOR ANY HELP.
For the roate, there is a example in this website.
(http://www.gamefromscratch.com/post/2012/11/18/GameDev-math-recipes...)
I want to do the same thing for rotating. And can move at the same time.
I am making a paper toss kind of game in Unity3d. I am implementing wind effect using constant force. I wanted to know how to make object fall in line with the target ie, if the object gets over the target, it should go in or fall in line with the target, not go behind or in front of the target. At present when I swipe applying a constant force, for different angles of swipe the distance moved by the object differs. Help would be much appreciated.
In FixedUpdate, use Physics.Raycast to check to see if the object is over the target. If so, set the x and z values of rigidbody.velocity to be zero (assuming y is the up/down axis in your game world) and disable the ConstantForce component (i.e. gameObject.GetComponent<ConstantForce>().enabled = false). Note that this won't be most realistic of movements, as it will seem like the object suddenly moves straight down when it goes over the target -- but it sounds like that's what you want.