Platform Grills Scroll Animation - 2D Game - unity3d

I want to add platform scroll animation just for visual effect purpose. Because I have started moving platform objects using Physics.
But now I want to add some animation for the ground platform grills so that moving objects will look more natural.
Here is the platform for that I want to add scroll effect or animation:
I want to scroll the grills those exist on the platform either on the left or right side.
Please give me some idea :)

Related

Unity 2D and UI rendering issues

I have been developing a game for a little while now and have started to notice rendering issues with the Unity3D engine. The poop emoji is supposed to appear in front of the floor tile but this isn't the case here. There are more depending on how you position the camera. They are both on the default layer and I have no idea what the cause would be.
If multiple sprite are on the same sorting layer and the same order in layer index you cant be sure which one will be on top of others. It could change anytime depending of the camera position or even on game session.
To be sure of your rendering , use the order in layer and set a higher value to the emoji than the floor.
Note : I use the 2020.2.0b unity version. Your inspector could look different but the Order in Layer should be there.

Move player in all directions with touch?, Unity

I was creating a basic scenario in Unity. Thi scene have 1 cube in the center of the room, and 1 camera(player).
I need to move the player around the cube like if was flying ( with movements at the top, bottom, left, right, inside and outside), very similar to when we move freely with the mouse on the development screen.
I need make this movement with the touch.
How can i to do?
Thanks!!
You can achieve almost all movements you want using a standard fps mobile controller: 1 joystick and a slide area for rotation. Your forward movement will be your player's forward direction(with W in unity you move always forward) and of course transform's left/right for strafe.
The tricky part is move up/down part(even in Unity editor you have to use 2 extra keys, Q&E) but you can always move up/down just looking in that direction.
if u use the unity standard asset 'cross platform input' (which is available in the standard asset pack for free,) then anything you program with a mouse event or click, will automatically call the corresponding touch event if use on a phone.

swift physicsbody is not matching up to image size

I have two nodes, player and platfrom. Both have a physicsBody around them. My player is still and the platform scroll by an SkAction. when the player reaches about half-way on top of the platform it falls threw it.
player.physicsBody=SKPhysicsBody(rectangleOf:player.frame.size)
player.physicsBody?.isDynamic=true
player.physicsBody?.allowsRotation=false
player.physicsBody?.affectedByGravity=true
platform.physicsBody=SKPhysicsBody(rectangleOf:platfrom.frame.size)
platform.physicsBody?.isDynamic=false
the platfrom set up is.
plat.size=CGSize(width:(self.frame.width)*2,height:(self.frame.height)/3)
plat.anchorPoint=CGPoint(x:0,y:0)
plat.position=CGPoint(x:0,y:0)
plat.zPosition = 2
addChild(platform)
I tried using this instead but player still falls down
plat.physicsBody=SKPhysicsBody(rectangleOf:CGSize(width:platform.width,
height: platform.frame.height))
I want the nodes to act like a solid object, in that they don't overlap each other when the player moves. Also it there an alternative method I can use. I don't really like working with physics.
An alternate to working with physics is to use the recently added to iOS 10 SKTilemapNode to create the background. Each tile can be tagged with data to indicate if the tile is ground or not. You then focus on how the player moves relative to the tiles. There are currently not a lot of examples to show this working, the WWDC 2016: What's new in SpriteKit shows this briefly. Other resources include a top down example which shows at least how to build the background tilemap and some background info on why physics engines don't provide the best experience for platformers. Kenney's is a good source of tiles for platformer artwork.

How to move a tile (sprite) with drag and drop in Unity 2D?

I would like to move a tile with drag and drop in Unity 2D. The tile is a sprite. The scene is an 'Unblock me' or 'Blocked in' like gameplay.
Because the tiles in real life correspond to physical objects it seemed be to a good idea to model them with colliders and rigidbody. The border of the table surrunded with invisible colliders. I hoped these will constrain the moves of the tiles realistic, when the player moves them.
Then I implemented a simple (mouse based) drag and drop behavior which is worked perfectly except the moved tile penetrates to other tiles and the border, and sometimes jumps over them. Then I learned if I am overriding physics by explicitly setting transforms position (which I do exactly in my drag and drop implementation), this will happen. OK I accept, I should set only forces, ect. on rigidbody never directly the position.
Now the question:
I am stuck here. I still want to drag and drop like user experience, and some realistic visual result. When in the real life a player moves a tile, it seems it is "glued" to its finger. How can I achieve this (ot at least similar) with just applying forces? Any suggestions or point similar existing sample/blog code?
(I know as a backup plan I can omit all the physics and constrain the tile positions by code, and create some tweens to move the tiles. Is the real solution (what I am asking for) so complicated I should vote on this backup plan?)
Edit
According to comments I've added a video:
There is nothing wrong with the way you are manipulating your dragging. The beauty of developing is being able to do things in your own way. If it works for your game, then don't fret.
Now, i recommend:
Create a new physic material. Assets > Create > Physic Material
Set your new physic material inspector settings both to 0
Attach the physic material to all your wall object colliders. This should allow for your object being dragged to move smoothly against the walls without chopping.
Do a check to see if your mouse is over another collider. If so, then stop the movement in that direction.
Since your movements seem to always be on a single axis, on collision, tell your object to snap to the edge of the wall object. You know the Wall position and scales, also you have the position and scales of the object being dragged. with that you can write a function that will offset it to the correct position when the collision occurs.
Let me know if any of that works out :P

Detect hand swipe gesture in Unity using Kinect with OpenNI

I have a 3D model in my Unity project and I have a JavaScript that rotates the camera based on keyboard arrow keys (left/right).
Now, I need to have a script that detects a horizontal swipe hand gesture and returns a vector that I would use to rotate the camera.
I am using the ZigFu SDK with PrimeSense OpenNI/NITE. The ZigFu SDK comes with sample scripts, one of which is SwipeDetector - I am wondering how does it work?
My setup:
I have 3 GameObjects: a 3D model, a MainCamera, and a Directional Light.
So, how do I use the SwipeDetector script in my project? The way I do it right now is 1)Create an empty game object "SwipeDetection", 2) "drag and drop" the SwipeDetector script from ZigFu. I've put in logs in the SwipeDetector script, but I don't see them.
The Zigfu bindings (I'm assuming you're using version 1.4?) dont have a SwipeDetector sample, but they do include a SwipeDetector MonoBehaviour. The SwipeDetector detects vertical and horizontal swipes, but unfortunately doesn't detect the velocity of the swipe.
You have a few options:
Use the provided Swipe Detector, and rotate the camera by a fixed amount every time you detect a horizontal swipe (SwipeDetector_Left or SwipeDetector_Right events)
Use the provided Swipe Detector, start rotating on Swipe, and stop rotating on the SwipeDetector_Release event. This would be similar to pressing on the arrow keys (assuming you have the same behaviour on keydown/keyup events)
Keep track of the hand velocity, and check its value when the swipe occurs. Use this value to rotate the camera. You can keep track of velocity by creating a new MonoBehaviour, and implementing Hand_Create, Hand_Update, and Hand_Destroy (look at any of the scripts in the HandpointControls folder). Keep a queue with the hand points from the last n frames. The delta between the newest & oldest points will be your velocity for those n frames (I recommend you start with 15 frames, or about half a second)
(This will be included in a future Zigfu release :))
Your game object setup sounds right - if you dont see any logs you may not be performing the 'focus gesture' correctly. Try waving or performing a tap towards the sensor - this should cause the Hand_Create event to be called. Once you have a valid handpoint you should get the proper events from the Swipe Detector.
Also worth mentioning your swipe detection game object should have a HandPointControl component (added implicitly with RequireComponent) and that 'ActiveOnStart' should be true.