Unity -- 2d platformer sprite animation in different position - animation

I'm trying to make a simple 2D platformer game. So I got the walking and idle animations working for my sprite, but for some reason when it transitions to the run animation, the sprite is a little off the ground? Does anyone know how I could fix this?
The sprite looks like this in the two animations:
idle:
run:

There's a number of things this could be. Here's some things to consider.
Ensure that the location of the sprite hasn't changed. Do this by looking in the inspector.
Look at the anchor point for each sprite, and make sure they are at the same point.
Check for size differences.
Make sure the sprite is cropped correctly
Look at the animation state diagram to see if an unusual state change occurred.
I'm sure I could find more possible causes, but the bottom line is, take a look at everything you can think of that might be causing the issue. If you've tried that, then look around and see what else you can see. Finally, if that doesn't work, try asking here with everything you've tried included.

I had this problem too and just fixed it. it's actually simple. What causes this is the pivot of your Sprites. You have to go back to the sprite editor and set the privot of your sprites to the same value and that's it.

Related

scratch bounce then upside down

Above you can see my Scratch workspace where the ship on the left is upside down when it is running, and IT IS THE SAME CODE.
Is it a bug of scratch or some kind of other problem?
Make sure that the sprite is set to don't rotate in the info tab
Alternatively, you can add the set rotation style to (don't rotate).
It will make the sprite no longer rotate all around.
Otherwise, if you want to make it look like it is walking rather than just looking in a direction while walking, replace the parameter don't rotate to left-right
I use Scratch 2 for kids programming classes and as a beginner at this object, at first I had the same problem that confused me a lot as to what would provoke the Sprite to turn around.
It turned out that Scratch makes the character rotate when it bounces off the edge (I guess that the reason is not functional).
Anyway to solve it I added the move->set rotation style (don't rotate) before (the position doesn't matter, could as well place it after) the if on edge bounce block.

Using "broken" option in animation curves doesn't work for rotation

I'm making a game using sprite sheets, but I was curious to see if I could animate other sprites into the animation. Indeed, it is possible, however the animation's curve has to be dealt with, or else you have one part choppy, and the other very smooth. I found this resource which helped: http://answers.unity3d.com/questions/893479/how-to-make-not-smooth-multi-sprite-animation.html
While the "broken" curve works for translation, it seems to be without effect on rotation.
This is what happens instead:
As you can see the curves are straight, but the animation does not reflect that.
I'm wondering if this is a bug?
I haven't found any other resources mentioning it. I realize I can simply create another sprite sheet, but it'd be efficient if I could do it in this manner, I believe.
Try setting different interpolation modes from context menu of rotation property. Eeuler angles( Quaternion Approximation ) should be suitable for you

Clip (don't render) anything outside of a cube / box, like Godus

I've been trying to work out how to clip / not render anything that falls outside of a box, exactly like how Godus works (pictured below: notice the clipping at the back)…
Originally, I experimented with constructive solid geometry (CSG) to manually split and clip every object that falls on the box boundary. However, this is hugely computationally intensive and isn't feasible for a system where I want to be able to scroll around and have the clipped area update in realtime.
Is there a way to achieve this in a way that runs in realtime without modification of the objects, perhaps with shaders or something else? I'm new to shaders and still don't quite understand them enough to know how to implement this myself.
I appreciate the help!
Can the camera go outside of the box? If not, just put a big cube around the area you want and give its inside faces a material.
If the camera can go outside of the box (which would be weird, since you'd be able to see through the back of the meshes) one thing you might try is using vertex colors to make all faces outside of your box the same solid color as the background.

CALayer obstacles?

I am putting together a 2d RPG in Cocoa just for learning and for fun.
I've got the sprite moving around and animating just fine... but not sure how to approach making obstacles. Take for example Mt. Zozo here. I don't want Setzer falling off a cliff, or climbing up on those dangerous looking rocks!
I was thinking that I might have to draw in some layers where I don't want him to move and put some code in my move keydown methods that test that the resulting position doesn't contain a point that is also contained by an 'obstacle' layer. But that seems really not generic and a lot of work.
Any thoughts?
Thanks!
In the end, pretty simple.
Remember that I am using a 32x32 px grid for sprite movement.
Just put down layers wherever you don't want the character to move, and then when adding possible the movement tiles, test if the position of the movement tile is the same as the obstacle.
if (upOne.position.x == obstacle.position.x && upOne.position.y == obstacle.position.y)
upOne.hidden = YES;
I tried using contains point but that was problematic. Anyways, this worked :)

How do I animate clouds?

I have 3 nice and puffy clouds I made in Photoshop, all the same size, now I would like to animate them so they appear like they were moving in the background. I want this animation to be the base background in all my scenes (menu,settings, score, game).
I'm using cocos2d, I have setup the menus and the buttons so the work but how do I accomplish this?
I was thinking to add this as a layer, any other suggestions?
Can anyone show me how some code how to make this please?
David H
A simple way to do it is with sine and cosine. Have slighly different parameters (period and amplitude) to ensure that the user doesn't realise (as easily) that they are programmatically animated.
You may also want to play with animating the opacity value. I'm not sure if layers have those, otherwise you'll have to add the clouds to separate nodes or images and applying it to them.
It's hard to be more specific without knowing what the images look like.
The simplest way to animate anything is to add the sprite to the scene, set the position and call something like...
[myClouds runAction:[CCMoveBy actionWithDuration:10 position:CGPointMake(200, 0)]];
This will slide the sprite 200px to the right over 10 seconds. As Srekel suggested, you can play around with some trig functions to get a more natural feel and motion paths, but you'll have to schedule a selector and iteratively reposition the elements.
The more difficult part of your questions is about getting the animation in the background of all scenes. Keep in mind that when you switch scenes, you're unloading one node hierarchy and loading a new one. The background cannot be shared. You CAN, however, duplicate the sprites and animation in all scenes, but when you transition between them there will be a jump.

Resources