Animation in unity2D - unity3d

I am trying to animate my main character's attack , but when I add all the frames together the character shifts a little bit back and forth to compensate for the change in width. Only the characters arm is drawn differently but since it changes the width of the entire picture ,unity changes the position of the character to compensate for the change in width.
I know it's hard to ask for help on animation since I cannot provide a video of my problem , but if anyone has an idea on how to solve it?

In the sprite editor, make sure the character sprite's pivot is always in the same spot.

Related

Unity 3D text disappears when I rotate the camera

New to Unity.
I think it's quite weird. What I was trying to do is to make the words on the newspaper flow like water. I created a plane for the newspaper, and I added a 3D Text object.
It worked well at first but when I rotate the camera(not the camera in the scene, but the camera with which you do all the editing), the text simply disappeared at some angles (particularly from below). The main camera had the same problem. It saw the text at some angle and couldn't at some other. I am sure that the texts are positioned right in the viewing frustum.
Some screenshots:
The text can be seem from here
And it cannot be seen when the camera moves a little bit down
Or from another angle, the text is selected
It is in the viewing frustum. But the main camera does not see it
It seems like your text and background are on the exact same coordinates (for example 1,1,1). By doing so, you let Unity decide which is more important to show on the foreground, which makes it dissapear sometimes.
Try to move your text a little forward (for example 1,1,1.001), so it seems to rest on, instead of in the newspaper. Most of the time, that should fix the problem.
Is there some kind of transparency on the object?
Try to set it to opaque to check if this is the problem

UnityVR - Having the both renders display the exact same image for each eye

When Unity builds a VR project, by default it is set to make the two views stereoscopic. It slightly offsets the camera position of one eye to give the user a sense of depth.
For example a square will appear slightly to the left on the right view compared to the left view.
I want to make the camera truly monoscopic by removing the offset that is created when i build the project. Each camera should render all objects in exactly the same position for both eyes.
One of things i tried was creating two camera and setting them to the left and right eye. Then i manually set the position/rotation of one camera until it looked monoscopic
It worked fine on my pixel phone, but as soon as i put the project on my test phone i noticed that the difference in resolutions messed up the view i was going for. The blocks were not in the same position when i looked at both renders.
If anyone has any solutions or ideas as to how i can go about this, i would greatly appreciate it.
Thank you!
You can still use 2 cameras, but instead of offsetting them, you can just make the width of the camera half.
Make 2 cameras, set their positions to exactly the same.
On the left eye camera, set the width to 0.5 and the x position to 0.
On the right eye camera, set the width to 0.5 and the x position to 0.5.
You should now have 2 cameras rendering the exact same thing, but twice across the screen, with no sense of depth.

How to create a trail effect in a rendertexture?

I'm trying to create a cumulative trail effect in a render texture. By cumulative I mean that the render texture would show the last few frames overlaid on each other. Currently, when my camera outputs to a render texture it completely overwrites whatever was there previously.
Let me know if I can clarify anything.
Thanks!
You could set the clear flag on the camera to Don't clear. This will prevent the clearing of previous frame on your camera and then will create this overlapping kinda like Flash movement style.
The issue is that everything will be kept on screen so if only the character moves then it is ok but if the camera moves then the effect also applies to environment and your scene becomes a big blur.
You could have two cameras for the effect, each with different rendering layers. One takes care of the items that should not have the effect and one takes care of those that are considered for the effect. This way you can apply the effect on characters and ignore the environment, if that is required else just go with one camera.

Swift: Giving a single, long string of text tilt physics

I am building an experimental reading app where the text passage is presented as a single line of text on the screen. The user will tilt back and forth to move the text strip backwards or forwards. What I have tried so far is:
Placed a UILabel inside a UIScrollView and manually calculating the ScrollView’s new offset depending on the current tilt. The text scrolls in an uncomfortable, jerky motion in this implementation most likely because the current acceleration equation is just a linear function. Also, I’d rather not reinvent the wheel since Sprite Kit already has tilt physics perfected, but it is just not readily applicable on text objects.
Wanting to use Sprite Kit’s buttery smooth tilt, I placed my text in an SKLabelNode and had its X coordinates match a SKSpriteNode that I gave tilt physics. This worked very well until the moment I added a paragraph’s worth of text inside the SKLabelNode. Then it turns into a black rectangle...
Stack Overflow discussions I have found concluded that SKLabelNode is not meant to be used in the way I desire and have suggested multiline implementations, or string to bitmap image conversion. Multiline is not an option for the way I want my reading app to work.
I found the code in
How do I add text to an image in iOS Swift to implement string to bitmap image conversion, then making that image an SKSpriteNode. The moment the image’s width exceeds 2000 (only enough space for a short sentence in 50 pt font), it becomes a black rectangle. I imagine up the text into smaller chunks to fit inside this 2000 limit will really complicate the code and make user statistics like words per minute much harder to calculate.
At the top is what I want the text to look like (user tilts left/right to read next/previous), and the black strip on the bottom is the black rectangle that appears if the width of the text is way too long :(
Does anyone have any suggestions for what else I could try? Once again, my requirements are:
The string must be presented as a long, single line on the screen
The user tilts the device to read forward/backward
The acceleration is smooth so it’s easy on the eyes :)
Perhaps you can try loading one sentence at a time into one SKLabelNode. You will also have a second SKLabelNode to act as the on-deck cache. When one SKLabelNode moves off the screen, you can position it at the end of the of the SKLabelNode currently on screen. That's how a table view in UIKit works. The only difference here is that your "table cells" are scrolling horizontally, and you'll have to perform the work to reset them after they move off the screen.

Cocos2D changes the colours in the last row of pixles in a sprite?

I have never seen this issue before, its very strange. Just wondering if anyone else has come across this too.
I have added a sprite to my game, its supposed to be the top left corner of a box to put text on to. I want to make it scalable without loosing anything so i have it broken up into sections. In the image above the one on top is the image itself, and then the one on the bottom is the image when its being drawn in the iPhone simulator.
Any idea why the last column of pixels on the right are altered? I have not scaled the image at all.
I don't know about Cocos2D, but in general terms what you've done here is to draw the image at a position that isn't an exact multiple of one pixel.
Consequently even without scaling you have resampled the image across a grid that doesn't coincide with the original image data, causing all pixels to be a bit off. It's just the right-hand edge is the most obvious case, since the resampling leaves you with a partial transparency here. But look at eg the two rows of purple pixels in the border: they're not the same, because your vertical alignment is off as well, causing a small amount of colour from the grey border below it to bleed into the lower row of purple.
Ok I actually figured it out this time. Cocos2D adds a bit of antialiasing to CCTextures. To stop it from doing this you need to call this:
[[mySprite texture] setAliasTexParameters];
to turn it back on you call this:
[[mySprite texture] setAntiAliasTexParameters];