|
I making a game which involves flipping gravity so that the player travels on the ceiling when space is pressed. The problem is that when gravity is switched round the camera doesn't switch round too which makes things very disorienting! Thanks in advance to anyone who can help out! [Edit] More detail: The camera is attached to a vehicle with this script:
using System.Collections; public class CarCamera : MonoBehaviour { public Transform target = null; public float height = 1f; public float positionDamping = 3f; public float velocityDamping = 3f; public float distance = 4f; public LayerMask ignoreLayers = -1;
} I've tried to make a flipping script like this: function Update() { if (Input.GetKeyDown(KeyCode.Space)) { ; transform.Rotate(0, 0*Time.deltaTime, 180); } } This camera flipping script works but not with the camera with a vehicle script attached at the same time. My guess is something in a that big script is messing up my little script...
(comments are locked)
|
|
Sorted. I attached a camera movement script to a cube, removed its mesh renderer and then made the main camera a child of it. I then added this script:
} to the main camera. This means the camera movement script and the camera flip script don't interfere with each other. There was almost certainly a better and more elegant way of solving this problem, but I'm not a programmer, I'm pushed for time and this works so it's all good :)
(comments are locked)
|
|
You need to rotate the camera by 180 degrees The problem I have is that I need a script which does this and I'm useless at scripting so I don't know where to start :S
Nov 23 '10 at 10:13 PM
ODPaterson
(comments are locked)
|
|
On an empty object, this should do the trick:
If you're planning on getting anywhere with your project, I recommend you take the time to understand any external snippet of code you're using. The Scripting Reference is your friend : http://unity3d.com/support/documentation/ScriptReference/Transform-eulerAngles.html Thanks, but it doesn't seem to work :S. I have a camera flip script but it just gets overwritten by the camera follow script. When I press space the camera view flickers to the right position for a millisecond but ultimately stays the same. If I could wok out what was doing that I'd be alright I think.
Nov 30 '10 at 07:35 PM
ODPaterson
(comments are locked)
|

Not enough info - you haven't said how the camera is controlled, or even whether the game is 1st-person or 3rd-person. If you still need help with this, edit your post to include more info (and perhaps your camera control code as well).