I`m writing a script, where I control the camera by pushing buttons and by mouse. I need camera always moves forward(where View Frustum is directed ), but it moves only on world axises. How to do it?
You could use
MyCamera.transform.Translate(Vector3.forward);
To move the camera forward, where MyCamera is of course your camera.
Related
I'm making a space game and I want the game to take place inside of a sphere or cube. I want the walls of the shape to render what's inside on the inside walls so it seems like endless space. Once the illusion of endless is in place I want to teleport the player if they touch the game space shape and teleport them seamlessly to the opposite side of the shape.
Edit: I just had an idea of how to teleport how I want. Maybe using ray casting to cast a ray behind the player and where ever that hits when they touch the edge of the shape to teleport to?
To answer question one I used a render texture. It's very close to the effect I want I just have to play with the perspective like they do with portals in portal 1 and 2.
To answer the my second question I went with raycasting. The player flys around in a sphere and casts a ray behind itself. Once the player hits the collision of the sphere they teleport to the point of the raycast. This works perfectly only for the fact when the player reverses on the sphere collider they escape the sphere flawlessly.
So I want to make a game with RPG movement, but it's more like a wave game, with static camera.
I want to move the character's face to make it look like it's looking at the mouse, but I didn't find how. I know how to rotate it but not how to rotate it with the mouse. Here are some images so I can explain better.
This will be when the mouse is either in 0,0 or outside the window
And this is when, for example, the mouse is in the right
You can get the coordinates of the mouse position in world space by using Camera.ScreenToWorldPoint. You could use the coordinates to find the right position for the eyes.
For a 2D topdown Unity project, I'm trying to make it so when the player clicks, a bullet comes out. The shooting is working perfectly, just there is a countdown on the bullet, and when the bullet is shot the countdown is always pointing towards where the player was facing. I'd like to make it so even if the player is facing sideways or up or down, the countdown always remains upright and readable.
Use World Canvas and use transform.lookAt to face it to your camera.
im working for 3rd person fighting game between two characters.
I've setup camera to focus enemy and player in same time like Naruto Ultimate Ninja Storm 4, but when camera collide with wall the view angle will be change and both characters will not appear on screen.
in Naruto Ultimate Ninja Storm 4 there is transparent wall around arena which leave empty space between visible object (wall,rock..) and player but allows camera to pass it.
my problem I don't find method to let the camera pass this transparent wall and stop player to pass it.
I tried to get tag of object in collision and disable collider of object when is camera or vice versa but that allow character also to go tought transparent wall
You should create 3 layers, if you haven't already:
Player
Camera
Wall
Put each GameObject in the corresponding layer, then go to Edit->Project Settings->Physics, scroll to the "Layer Collision Matrix" and uncheck the collisions you don't want to have. In your case, you want the collision between the wall and the player, but you have to uncheck the collision between the camera and the wall.
Also, to make this work correctly, make it so that none of the characters, walls, and camera are separate gameobjects.
This is also very useful to remove any unnecessary collision and boost your game performance.
I'm writing a game just now in Unity. The basic premise is there are a few objects on screen in 3d space which you swipe to destroy. I've done most of the hard graft but got stuck on something I think should be fairly simple.
I've written a touch controller which spits out the start, end and direction of a swipe. How can I use this to check whether the swipe line in screen coordinates intersects an object in 3d space? I've looked into Rays but can't seem to get it working when casting from anywhere but the camera. My objects do have a collider and I attempted (briefly) to use the collider bounds too. Just can't seem to crack it!
Any help is appreciated,
use "Camera.ViewportPointToRay" to shoot rays depending on which pixels are swiped. Bottom-left of the screen is (0,0) top-right is (1,1).