BEST代写-线上留学生作业代写 & 论文代写专家

成立于2015年的老牌留学生代写品牌-BEST代写提供超过百门冷热门留学学科的作业和论文代写服务。全网BEST原创,高质,准时的留学生代写。

游戏开发代写|31263 / 32004 Game Development Lab Week 8

游戏开发代写|31263 / 32004 Game Development Lab Week 8

这是一篇需要用到Unity的游戏开发代写作业案例分享

 

Getting Started

  1. Download the corresponding week’s zip file from this week’s module on Canvas.
  2. Unzip the project folder and open it in Unity. If there are any warnings about difference in versions,just continue. If this causes any red errors in the console once the project opens, notify the tutor.
  1. Within the weekly folders there are image and executable files starting with “Status…”. These files give you a preview of what is expected for each point percentage below.

a.If you are on Mac and the Status-100Percent App file won’t run, hold control and click (right click) then select Open, if there is a security warning, acknowledge it an press open again.

i.If you still have trouble, you may need to change the permissions of the file with the following command in a Terminal window:

chmod -R +x Status-100Percent-Mac.app/Contents/MacOS

b.If you are running the Windows executable on the lab computers, you need to copy the entire executable folder into Windows(C:)/Users/<student number>/AppLockerExceptions.

From there you can double run the .exe file.

Tasks Points Requirements

Scene Set-up

  • Drag the Floor prefab from the Project Window into the Hierarchy Window and make sure its position and rotation are zeroed.
  • Drag the Player prefab into the Hierarchy Window and make sure its position and rotation is zeroed and scale is set to 1.

o Change the Y position to 0.12 to have the character standing on top of the floor.

  • Create an Empty Gameobject in the Hierarchy View called BackgroundMusic

o Attach an AudioSource component.

o In the Inspector Window with the BackgroundMusic gameobject selected, next to AudioClip to see valid audio clips in the Project Window. Select the

BackgroundMusic audio clip.

o Make sure “Play on Awake” and “Loop” are ticked in the Inspector Window.

There is no ProgressEvaluator for this week. Please view the Status-100Percent video and executable, as well as the other Status images, to check your own progression.

CharacterMovement Script Variables and Methods

  • Create a new script called CharacterMovement
  • In CharacterMovement:

o Create the following member variables

 private Vector3 movement;

 private float movementSqrMagnitude;

o Create the following methods

 void GetMovementInput() {}

 void CharacterPostion() {}

 void CharacterRotation() {}

 void WalkAnimation() {}

 void FootstepAudio() {}

o In Update(), call all of the above methods in the above order.

o Delete the Start() method

  • Attach the CharacterMovement component to the Player gameobject.

Movement Vector

  • Go to the Input Manager window and make sure that:

o The Horizontal Axis has Positive Button is set to “d” and Negative Button set to “a”, Gravity 3 and Sensitivity 3.

o The Vertical Axis has Positive Button is set to “w” and Negative Button set to “s”,Gravity 3 and Sensitivity 3.

  • In the GetMovementInput() method of the CharacterMovement script:

o Set the x value of the movement vector variable to the value of the Horizontal input axis (tip: see Input.GetAxis(….)

o Set the z value of the movement vector variable to the value of the Vertical input axis.

o Store the squared magnitude of the movement vector in the movementSqrMagnitude variable (tip: see Vector3.sqrMagnitude)

o Print the movement vector out to the console.

Position and Rotation

  • In CharcterMovement, create a public variable called walkSpeed with a default value of 1.75f.
  • In CharacterPosition() in the CharacterMovement script:

o Move the current gameobject in the direction specified by the movement vector and Transform.Translate().

o Press play and use the a,s,w,d to move.

o Combine the movement vector with the walkSpeed variable and make it frame rate independent when moving the game object.

o Press play and move around

  • In CharacterRotation()

o Set the Player gameobject’s rotation using the direction specified by the movement vector (without the walkSpeed variable or frame rate independence).(tip: see Quaternion.LookRotation(…) )

o Press play and move around

  • Notice that the position update is all wacky now with the rotation

o This is because the Transform.Translate() defaults to local space translation, which is affected by an object’s rotation.

o Set Transform.Translate() to use Space.World.

o Press play and move around.

  • Notice the warnings and that the character pops back to facing forward after stopping its movement.

o Only do the rotation if the movement vector is not a zero vector.

o Press play and move around.

  • Notice that the Player moves faster when moving diagonally than moving just vertically or just horizontally.

o This is because a vector of (1,0,0) (e.g. moving positively in the x-axis) has a magnitude of 1. However the vector (1,0,1) (e.g. moving diagonally in positive x and z) has a magnitude of about 1.4.

o In GetMovementInput(), after setting the x and z variables of the movement vector but before the sqrMagnitude of the movement vector is stored:

 Use Vector3.ClampMagnitude(…) to clamp the magnitude of the movement vector to 1.0f.

Animation

  • Comment out the console printing of the movement vector.
  • Add an Animator component to the Player gameobject.

o Press the circle button next to Controller to see valid AnimatorControllers in the ProjectWindow. Assign the MovementAnimator controller.

o Press the circle button next to Avatar and select PlayerAvatar.

o Make sure “Apply Root Motion” is unticked, “Update Mode” is normal, and “Culling Mode” is set to “Cull Update Transforms”.

  • Go to the menu option “Window->Animator” and dock the Animator Window somewhere such that you can see the Game View and the Animator Window at the same time.
  • Select the Player gameobject to see the state machine of the MovementAnimator
  • Select the Parameters tab in the Animator Window and create a new parameter called

MovingSpeed.

o Select the transition line that is pointing between the states PlayerIdle to Walking.

 In the Inspector, untick “Has Exit Time”

 In the Inspector, under Conditions, add a new condition that MovingSpeed is Greater than 0.1.

o Select the transition line that is pointing between the states Walking to PlayerIdle.

 In the Inspector, untick “Has Exit Time”

 In the Inspector, under Conditions, add a new condition that MovingSpeed is Less than 0.1.

  • In CharacterMovement, create a public variable to store the animator of the Player gameobject.
  • In the WalkAnimation() method

Set the MovingSpeed parameter of the Player’s MovementAnimator to have the value of the movementSqrMagnitude.

  • Press play.
bestdaixie

评论已关闭。