Четверг, 26.12.2024, 17:03 Приветствую Вас Гость


Allunity3d.ucoz.net

Главная | Регистрация | Вход | RSS
[ Обновленные темы · Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Cтандартный unity3 из ресурса MouseLook скрипт
allunity3dДата: Среда, 12.05.2021, 23:35 | Сообщение # 1
Рядовой
Группа: Администраторы
Сообщений: 16
Репутация: 9
Статус: Offline
Раньше именно за управление камерой MouseLook.js  отвечал, в предыдущих версиях Unity c 1.x  версиях.
MouseLook перенесенный на C# FPS Controller


using UnityEngine;
using System.Collections;

/// MouseLook rotates the transform based on the mouse delta.
/// Minimum and Maximum values can be used to constrain the possible rotation

/// To make an FPS style character:
/// - Create a capsule.
/// - Add the MouseLook script to the capsule.
///   -> Set the mouse look to use LookX. (You want to only turn character but not tilt it)
/// - Add FPSInputController script to the capsule
///   -> A CharacterMotor and a CharacterController component will be automatically added.

/// - Create a camera. Make the camera a child of the capsule. Reset it's transform.
/// - Add a MouseLook script to the camera.
///   -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.)
[AddComponentMenu("Camera-Control/Mouse Look")]
public class MouseLook : MonoBehaviour {

public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;

public float minimumX = -360F;
public float maximumX = 360F;

public float minimumY = -60F;
public float maximumY = 60F;

float rotationY = 0F;

void Update ()
{
if (axes == RotationAxes.MouseXAndY)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;

rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);

transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);

transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
}

void Start ()
{
// Make the rigid body not change rotation
if (GetComponent<Rigidbody))
GetComponent<Rigidbody).freezeRotation = true;
}
}

ТЭГИ
unity, unity3d, tutorial, c#, programming, fps, tutorials, games, coding, easy, unity tutorial, beginner, brackeys, game, development, game development, mouse, how, to, unity 3d, learn, controller, mouselook, camera, shooter, develop, basics, howto, basic, input, 3d, person, look, gamedev, player, character, script, code, course, assets, tip, movement, asset, unity (software), first-person shooter (media genre), scripting, multiplayer, mouse look, how to, fix, move, first person, gravity, unity 5, physics, game dev, free, jumping, unity5, rigidbody, new, dev, indie, game design, csharp, shooter game (media genre), c++, velocity, fall, sprint, crouch, free look, first, design, unity3d tutorial, learning, third, hands, how to use unity, weapons, c# (programming language), how to make a game, first person controller, unity fps tutorial, teach, set, hand, up, first person shooter, help, smooth, javascript, please, tricks, 2d, operation (game), rotation, cinemachine, unity tutorial for beginners, unity mouse look, unity 3d tutorial, input system, unity game development, raycast, need, models, eye, model, simple, control, controls, software (album), eye (song), tips, free (business operation), shooter (film), vision, 3rd, mouse-look, quick, firts, fps shooter, unity 3d tutorials, gaming, c+, third person camera, unity technologies, playmaker, blender, stairs, slopes, ground checking, animation, walking, indie game, charactercontroller, unity 2d, youtube, guide, c sharp, developer, unity5 scripting tutorial c#, unity2d, zunity, unity5 player tutorial, how to select player with unity3d, unity 5 tutorial characters, puppet, standing, layermask.getmask, unity5 asset tutorial c#, unity 5 rpg character select, procedural, unity3d choose character, unity 5 character select, unity5 character asset selection, horizontal, unity error, choose character with unity5, editor, unity c# tutorial, the namespace already contains a definition, burgzerg arcade, vector3.smoothdamp, smoothdamp, out hit, hit.distance, querytriggerinteraction, game development tutorial, c# tutorial, how to program, error standard assets, unity firstpersonshooter namespaec error, namespace unity, unity namespace already contains definition, equal reality sdk import, based, enabled, skeleton, rig, the namespace already contains a definition for firstpersonshooter, unity namespace error, layermask, physics.raycast, scripts, unity fire projectile at target, unity gun shoot script c#, unity shoot projectile in direction, unity shoot bullet script, unity shoot towards mouse, unity 2d topdown shooting, camera controller unity, unity programming, unity c#, unity shooter tutorial, third person controller unity, aiming rig cinemachine, tuto unity, ray, upln, unity pour les nuls, formation unity, unity 3d games, unity shooting 2d, unity point and shoot, new ray, how to unity, how to cinemachine, 2020, debug.drawray, raycast unity, wow, strike, counter, unity3d player selection, raycasthit hit;, hit.point, csgo, devlog, ai, raycasting, third person camera cinemachine, unity cinemachine, unity engine, education, 3rd person camera, dani, game engine, third person game, walker, unity navmesh tutorial, survival game, survival tutorial, game tutorial, brackeys create a survival game, video game (industry), video game development (industry), game making tutorial,
Прикрепления: MouseLook.zip (0.9 Kb)
 
  • Страница 1 из 1
  • 1
Поиск: