Adding Smooth Rotation To 2D Character with only vertical movement - c#

If you've seen the picture my space ship is stuck on on place and can only go up and ddown, now that's not the problem the problem is that while it goes up or down, it looks really bland and i want to add some smooth rotation to that, but please I do not know what mathf lerps and slerps are, and they are confusing everyone keeps suggesting only that so if you have a different answer please tell me that!
but as always anything is appreciatable than nothing!
I have tried the Mathf Lerps and Slerps and can't seem to understand where to add them and what variables i should create just to make it work!, so if you have an answer please suggest it!

Related

Unity Rotation Issue - Character Feet look towards movement direction

My question seems simple but I am also very simple and cannot figure this out. The thing is, I´ve got an IK system for the Character's legs. I need the character's feet to "look" in the movement direction.
If I do this: rightLegCurrentRotation = Quaternion.Euler(-transform.up);
The Character´s feet "look" flat down, just as I want, however, if I use the movement direction and do anything but fall down (Since that gives me the same value as -transform.up) the feet´s rotation completely goes wild and makes no sense.
Not sure if I´m explaining myself but essentially what I need is the player's feet to lay flat towards the given direction, kind of like this.
Please let me know if I don´t make sense, quaternions are a real pain and I hardly understand what I´m doing. I am in dire need of help.

Is it possible to move 2D character at a specific angle?

I have started developing 2D isometric game in Unity, but i'm struggling with the movement. I want to move my character at a specific angle. To be more specific with you and give you better idea what i like to achieve is to create movement like in "Bouncy Bits"
Here is a video of their gameplay: https://www.youtube.com/watch?v=A6xA4RzuRcM&t=19s
I would love to achieve that kind of moving to my player including him to move forward alone in that same angle without me pressing any keys.
Would really appreciate if someone could help me out, by giving me a code or explain me what i exactly need to do.
Move your character on vector.forward, which is equivalent of (0, 0, 1) on the Z axis. Put your camera on that front angle how they have it. It would look the same.

Objects having same distance/radius from the center (camera) in Unity 3D

It's a 360 Video application on Unity 3D.
I want to place several objects around the camera (which has a fixed position), but I need this objects to have the same distance (same radius) from the Camera (which is the center). How can I do this? Either on Editor or by code.
I have been manually displacing objects around the camera, by dragging them by arrow tool. But it's as inaccurate as a pain to do. :)
Any light on this would help me a lot! Not only me, but anyone working with 360 videos in Unity.
Thank you all in advance!
To solve your problem, an easy solution would be to add a child "child_of_camera" to your camera and then add a child "child_of_child" to the "child_of_camera".
Now that you've done this, move the "child_of_child" away to however far from the camera you'd like it to be. After this, apply the random rotation you'd like to "child_of_camera".
Duplicate "child_of_camera" to however many objects you'd like on screen and then rotate them all to your preference.
Now, when you're moving around the camera, these children will follow along with the camera.
If you're looking so that the rotation of the camera doesn't affect the objects there are two ways you can handle this:
Place camera and "child_of_camera" (this name would now be misleading and should be renamed) under an empty GameObject and move "empty_GO" on the X,Y,Z axis instead of the camera.
or
Create a quick script to attach onto "child_of_camera" so that it always sets the "child_of_camera"s world space rotation to Vector3.zero.
As I stated in the comments, this solution is most likely not the optimal way to fix your problem but it is definitely a very simple solution that is easy to understand and implement. I hope it helps.

Unity How to achieve orbit swapping effect?

Let me get straight to the point. So, have a look at below picture.
Try to imagine this with the context of 3d. you are in first orbit and when the user taps you want to be in second orbit which is inside the circle. I tried doing this with animation but cant have better control over it and obviously not desired result. Let me show even better picture. Same thing as of first picture.
So, anybody have idea about any formula or code to move ball in such a way.

C#: How can I tell which side a collision has occured on?

I think the title is rather self explanatory but just to clarify I am trying to figure out how to tell which side the collision has occured on.
For a bit more detail, I'm trying to make a maze-like game so I can't simply stop all movement upon a collision. Instead I need to be able to tell which side the collision has happened on so I can block that direction.
Any help is appreciated and if there is a better approach to this issue, I'm all for trying it out.
I hope this is enough details but if you need anymore, ask and I'll edit. Thanks in advance.
[edit]
#viggity - No, I'm not using any specific game engine and I would post the current "detection" code but it's a little, absurdly, robust.
#Streklin - I'm using the this.Paint event to draw onto the form itself as it was recommended I start by doing that to get better at drawing real time. I'm also using a location that's updated each time the timer ticks based on what I press (left, right, up, down). Yes the maze is tile based. Currently it only consists of 3 colors even. I'm not a very advanced programmer.
#Eric - Definately a one-d game. Again, I only have 3 colors, the lines are black, the background is white and the square (the user) is green. I'm using the DrawImage() with Bitmaps to draw onto the screen.
[edit psuedo-code summary]
foreach(Wall _wall in walls)
if(player.intersectsWith(_wall))
stop movement;
#JeffH - I'm not really sure what you're asking as that's pretty much all there is besides testing code that I was using to try and get it working. The only thing I left out was the if statement to check if it was the x axis or not so that x and y could move indepedently from each other. So instead of getting "stuck" because you touched the wall, you could slide against it. I didn't see the point in including that though since the problem occurs before that.
Assuming you're talking about a 3D game here.
The normal of the face you can see points towards you, so the dot product of your direction vector with the face normal will be negative. If it's positive then you are coming at the face from the back.
If it's zero you're travelling at right angles to the face.
| <---------- your direction of travel
|
|----------> <- face normal
|
| <- face
If you're not in 3D then you could store the direction the wall is facing (as a 2D vector) and do the same dot product with your 2D direction of movement.
Based on your edit you can only go one direction at a time? Or can you go in diagonal directions? If it's the later, ChrisF has provided you the answer in 3D and the corresponding information for 2D. If not, you should just have to stop travel in the direction of travel - since there are only four possibilities it should be easy enough to check them all for simple starter game.

Categories

Resources