Progress Report # 2 – Transform Objects and Enter Collision

Currently, in the development of a 2.5D shooter game, where one needs to shoot enemy AI and control the movement of the character in order to provide the player movement and control over the first-person movement of the game. This is done by using the camera and control using the movement using a player movement script. Namely, by using transform and movement within the game using transform.position.

Using vectors in order to manipulate the movement of the enemy and correspond to the camera movement of the controller, the use of motion by transform and rotation in angle helps to move the character around. Namely, using this script in order for character to move via visionPoint, namely, a Transform variable:

Vector3 deltaToPlayer = player.transform.position – visionPoint.position;
Vector3 directionToPlayer = deltaToPlayer.normalized;

Vector3 helps with the player object. Normalizing the direction of the player helps set the variable return to 1. Helps to change vectors.

Using trigonometry to help the direction of Vector3, the script uses the following formula:

float dot = Vector3.Dot (transform.forward, directionToPlayer); -> This helps move the enemy object so that it could face the direction of the player.

Later, the design for the distance is derived from the magnitude, manipulating the movement of the Enemy AI.

float distanceToPlayer = directionToPlayer.magnitude;

Afterwards, confirming a check to see if the Vector is moving based on the movement of the player and performing a raycast to see if it fits. In addition, adding a function helps to transform the position of the Vector based on the position of the player:

transform.LookAt(lastKnownPlayerPosition.Value); <- Faces the direction of the player
transform.localEulerAngles = new Vector3(0,transform.localEulerAngles.y,0); <- Rotates an angle based on the direction it provides.

Once it’s done, update the game using the update() function and the Enemy will face you.

——

Additional research involves adding effects to the game in order to provide optimal output to the 2.5 shooter game. Namely, the gun and its effects. To ensure that it moves forward and that, when hit with the enemy, it is destroyed using the Destroy() function. The Enemy AI is updated to suit this function by making an if function using OnTriggerEnter() which helps to interact object with a collider. Meaning, the enemy, when interacted with collider (Namely, a bullet) leading to the enemy to “vanish” namely, using the destroy function. Of course, bullet script needs to be created to develop from this. The bullet is instantiated, thus bringing the gameObject bullet into view when using a control function (namely using Input).

The bullet then interacts with the object and triggers the effect from the script. Other effect varies depending on the script. But simply using the instantiate on a game object makes the object appear when inputting a certain key. And then, when triggered with the bullet script, the bullet spawned. The bullet fired forward using instantiate and using the shoot function, the object is shot. One is then used to develop further on the shooter game. Later, this will come to develop more on the game’s programming and more onto the AI, which currently is still not developed properly at the moment. Perspective differ based on use of code, hence this may possibly not be the correct code to use but it’s a suggestion that could possibly lead one to the direction that could help direct the code into a workable project.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s