Hi all.
Im working on a 2.5D side scroller and need the world to rotate 180 dgrees at giving point in time.
i know that one can do a transform.rotate on a single object but my issue is that the whole level is made up of alot of objects.
So can i do the transform.rotate on the main camera or do i need to group all the level objects into on and then transform.rotate?
you mad? that will make your FPS go down
first of all, every attached object’s (attached to your world) Vector3 positions will be changed and recalculated every frame on and on and on.
secondly whenever you will shoot a bullet other than raycast (which is instant), your bullet will change trajectory, because the whole world has changed it’s transform
and thirdly… attach your main camera to an empty game object as a child. Place game object where you want camera to look at. Let’s say Vector3(0,0,0) or Vector3.zero in short. Use script to rotate empty game object and Mathf.Clamp the values. So where ever empty game object will rotate, camera child will follow it without need to translate or rotate it yourself with heavy math.
Next for cutscenes add some gizmos or other empty game objects and make camera to.LookAt them, still keeping it’s distance, transform and rotation from parent object
Ahh, no, that is totally different story. Can you please provide some example game title, i’ll look up for it in youtube. Sorry i don’t really have an idea on what are you trying to achieve then. But yeah, main idea is not to rotate world, but rotate camera, and to simplify things, rotate empty object as camera’s parent, that will be easier than doing math. You don’t need to rotate player, you can have that empty gameObject attached as child to your player and have camera to be a child of game object. So gameObject is a parent for camera, but child of player… and player is a parent to both of them. That should give you more freedom
Ha! That is achieved very simple.
First of all say bye bye to Transform.translate and such. You will be working with rigid body, it’s velocity and FixedUpdate()
Second search for Faux Gravity script on forum. There are i believe 3 awesome scripts. I used original author’s and it works.
And again, try avoiding math as much as possible (as in less calculations i mean, if you can trick it)
Now for this to work, you must remember, that you cannot change Unity’s built-in gravity. However you can switch it off and use your own! That is what Faux Gravity script does.
You will be working only with Global Axis (Space.World) for movement and rotation of your character. Yes you will be rotating character. Why global axis? Because, you will be using player’s local axis (Space.Self) to constantly keep negative Y velocity. That velocity will keep pushing player down, simulating gravity, no matter how he rotates in global axis. Yes less math again, woot!
Here’s an image on how you need to do it:
Your Hero (player) will be a parent for your camera. That is all! As player rotates in Global Space, so will camera. But player’s Local negative Y axis will keep pushing player “down” acording to it’s rotation in Global environment. Camera simply follows along, no scripting, math or rotating the world.
EDIT: Faux gravity (fake gravity - blue ring) is a child object of player too, but not camera. Both Camera and Fux Gravity empty game object are equal children of Player parent. As player rotates, so does camera and gravity.
hmmm turns out that this isent the way to go for me
I my case im not interested in F’ing around with gravity , what i need to do is to rotate the platforms in the level 180 degrees when the hero flips a switch or collides with a trap.
Found this vid
and thats the effect i want.
my maine issue is that the level it build with many many different objects and how do i groupe these objects together so the level groupe has a centered ancher point and dosent rotate ascrew
use empty game objects as parents to make groups then
don’t know why you did not like my idea, but:
you will have to learn and do alot more scripting
use math and geometrical equations.
there is no Fking around with gravity, it’s more like - improving it. All there is - making extra object, that will act as gravity by pulling objects to it. Simple. There are probably consequences, but it’s a huge knowledge-time trade off
i do like the idea of Faux gravity
im just not sure that is the thing to use in my game. I dont need the hero to stick to the “roof” of the platform but rather the platform to change angle.
Maby im missing something i the Faux script i found?!
What is the best way to go about that? Create an empty and nest all the platforms in there or parent them to a cube object and disable the mesh renderer ?
You can absolutely alter or turn off Unity’s gravity. See the documentation here. The easiest way to do what I think you’re trying to do is to rotate the camera, and when you do, set the gravity like so Physics.gravity = -cameraTransform.up; For reference, to “turn off” gravity, you’d simply set Physics.gravity = Vector3.zero
woah, did not know that one, that makes it even more interesting. That makes it even easier.
However if you wanted to use multiple gravities for different game objects or jumping between them (Mario style), this wouldn’t work, so faux script comes in handy in that case
Edit: made a quick glance at reference, yeah you can also switch it off with Rigidbody.useGravity = false;
I thought I might have had something for you, but after watching your video maybe not. Either way I had a similar style project started a while back, but it took a move to the back burner… it was a 2d / 3d game. A 2d side scroller with a 3d map / environment… kind of a side scroller that didn’t just go left to right. Here’s a link to the web player (it was just a test of weapons and world rotation using the 2d starter kit)
It has decent working guns and a bow and arrow style 2d weapon
Basic Controls:
arrows - movement
space - jump
left mouse - fire
1 - machine gun
2 - 3 shot burst
3 - shot gun
4 - Arrow
5 - Rocket
run to an intersection… if a white arrow appears you can press the up or down arrow keys to rotate the world to take the path
As I said before, this wasn’t fully functioning before I set it aside so there are problems, but you can see level rotation in and working
The world (all objects that are not the player are parented to a single object) turns on a pivot. You would freeze physics, then turn the world around the player (transform.RotateAround()…) Then resume physics and let it fly.
The Youtube video has so little World pivoting that it is hard to say that you should treat it the same, however, the parts that do, I would do the same thing. What I do see more of is a very cool camera effect that pushes the camera out further the faster you go.
Novashot. Your demo looks like a decent start, however, the total effect does not work so well because in your case, you literally just need ot rotate the camera. When you do your rotation then, none of the physics blocks move around. I also saw alot of shifting on the platform which was a little disconcerting. I think you were overthinking the concept of the game.