unity3d-keyboard control for visual rotation and movement

Source: Internet
Author: User

Move

Keyboard a move left keyboard D to the right to move the keyboard W move forward the keyboard s backward

Adws is the y-axis unchanged, move up or down

The move is the value assigned to which axis is moved, and the rotation is the axis to which the axis is assigned.

float h= input.getaxis ("horizontal") *time.deltatime*speed;
Float V=input.getaxis ("Vertical") *time.deltatime*speed;
Transform. Translate (H,0,V);

Lens to the left turn Q lens rotate Right E

if (Input.getkey (KEYCODE.Q))
{
Rotate along the y axis, i.e. rotate left and right
Transform. Rotate (0,-25*time.deltatime,0,space.self);
}
if (Input.getkey (KEYCODE.E))
{
Transform. Rotate (0,25*time.deltatime,0,space.self);
}

Lens up H lens down n

if (Input.getkey (KeyCode.H))
{
Transform. Translate (0,time.deltatime*speed,0);
}
if (Input.getkey (KEYCODE.N))
{
Transform. Translate (0,-time.deltatime*speed,0);
}

Lens up rotation z lens rotate down C

if (Input.getkey (KEYCODE.Z))
{
Rotate along the x axis
Transform. Rotate ( -25*time.deltatime,0,0,space.self);
}
if (Input.getkey (keycode.c))
{
Transform. Rotate (25*time.deltatime,0,0,space.self);
}

That is, from the previous and the left and right move, more up and down move

From the previous rotation around, more and more up and down rotation

unity3d-keyboard control for visual rotation and movement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.