Move camera upwards when character looks up (SOLVED WITH TWEENING)


#1

Hello. It’s me again. :confused:
My character has an animation where he looks upwards when the up button is held. I would like for the camera to move upwards a little when he looks up. I would also like the camera to move smoothly as well. When the up key is let go, the camera moves back to the player’s position. I tried to attempt this, but unfortunately failed. Does anybody know how to do this?

Note: My camera is it’s own object that always stays at the center position of the player and remains hidden at all times.The camera follows the invisible object attached to the player, not the player itself (This is so other mechanics in my game work correctly). Is it possible to move the camera object upwards by changing it’s Y position as long as the button is held? Thanks in advance.


#2

Ah…That’s hard when need a smooth transition dude.
I also want to know this.


#3

Please? Does anybody know how? I really need help with this… :slightly_frowning_face:


#4

Nevermind everyone! I just decided to give up on waiting for an answer and just do it myself.
Now with the new tweening behavior added in version 66, I was able to easily create exactly what I wanted in no time at all! :slight_smile:
Seriously, tweening is a GODSEND. I’m not sure how we all managed before it was added!


#5

How you did? Please make a post about that. (showing your events)


#6

Here you go (and sorry for the late reply)


For this setup, you need 3 objects: The player, a “Camera” object, and a “LookUp” object. Also, please note that these events are underneath the player’s logic.
Give the camera object the Tween behavior and tween the position of it to the Player’s center. For easing, I used “linear” over 400ms, but you can change this to whatever suits you.
Now, rather than center the camera on the player, center it on the camera object.
Now take your “LookUp” object and position it above the player as high as you want him to look up. For this example, I chose 150 pixels above the player.
Now make sure that at the beginning of every scene, that you create the camera and lookup objects, and hide them. Put this underneath the Player Logic to save time and optimization.

Now, when the character is looking up, tween the position of the camera to the center of the lookup box, using whatever easing and ms you prefer. When the player stops looking up, tween the position of the camera back to the player.

Finally, underneath the events that actually make the character look up (Which I assume you have already done), create a sub event that positions the camera object to the X position of your player. This makes sure the camera doesn’t go doing it’s own thing. If the character is looking up while moving, make sure you put a sub event with the same actions below that as well.
That should be about all. Hope this helps.


#7

Oh…Thanks a lot @Shadowbonnie7.:smiley:


#8

No problem mate. Did it work?


#9

Yes. And tween animations are really great