Notifications
bg
PS
Patrick Simonsen
Oslo, Norway
6
Likes
0
Followers
0
Connections
All
Articles1
Games2
Showcases1
Column4
Jobs0
TankAttack v1
TankAttack v1
Ruin someones battle royale
PS
7 months ago
Hmm the game gives a black screen in Chrome for me, but works in my Opera browser.
A big thank you to everyone involved with the Create with Code Live course. It has been so much fun and it has helped me getting more involved with my passion, video games. I hope I'll get to create a full game and that people will enjoy it at some point in time :D

In the meantime if anyone is reading this, please check out my submission for the last challenge. I know its got a ton of issues, but I'm pretty happy with how it turned out in the short time I've had :)

https://connect.unity.com/p/tankattack-v1-1

connect.unity.com
TankAttack v1 - Unity Connect
TankAttack v1
TankAttack v1
Ruin someones battle royale
PS
7 months ago
Hmm the game gives a black screen in Chrome for me, but works in my Opera browser.
I'm struggling to find solution for this, but maybe someone here can help. I've been testing some scripts I found on the internet but I cant find any that makes my Player Tank act just the way that I want it.
The thing is as I will show in this video, the script I've named M Rotate makes the turret on the tank aim right where I want it. But, it moves the turret instantly to where the pointer is.
I want to slow down the movement, and found a couple of other scripts that do this, but with all of them it refuses to aim precisely where I'm pointing. In some angles its a little bit of, in other angles its very off.

I'll add the code in comments.

PS
7 months ago
Mouse Look using System.Collections; using System.Collections.Generic; using UnityEngine; public class MouseLook : MonoBehaviour { private Vector3 worldpos; private Vector3 turretLookDirection; private Quaternion _lookRotation; private Vector3 _direction; public float RotationSpeed; private float mouseX; private float mouseY; private float cameraDif; public GameObject fpc; void Start() { cameraDif = Camera.main.transform.position.y - fpc.transform.position.y; } void Update() { // Turn the player towards the mouse LookAtMouse(); } void LookAtMouse() { mouseX = Input.mousePosition.x; mouseY = Input.mousePosition.y; worldpos = Camera.main.ScreenToWorldPoint(new Vector3(mouseX, mouseY, cameraDif)); turretLookDirection = new Vector3(worldpos.x, fpc.transform.position.y, worldpos.z); _direction = (turretLookDirection - transform.position); _lookRotation = Quaternion.LookRotation(_direction); transform.rotation = Quaternion.RotateTowards(transform.rotation, _lookRotation, Time.deltaTime * RotationSpeed); } }
PS
7 months ago
M Rotate using System.Collections; using System.Collections.Generic; using UnityEngine; public class mRotate : MonoBehaviour { void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Plane plane = new Plane(Vector3.up, Vector3.zero); float distance; if (plane.Raycast(ray, out distance)) { Vector3 target = ray.GetPoint(distance); Vector3 direction = target - transform.position; float rotation = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg; Quaternion targetRotation = Quaternion.Euler(0, rotation, 0); transform.rotation = targetRotation; } } }
Homework done! :D

G(
7 months ago
Reply@Greta C (GretaACN)How did you do it? I'm trying to get mine to work and I'm not sure how to :(
Thank you so much! I didn't think of doing that, it works perfectly.
PS
7 months ago
Reply@Greta C (GretaACN)How did you do it? I'm trying to get mine to work and I'm not sure how to :(
I see now that I have the playerAnim.SetFloat("Speed_f", walkingSpeed); three times which is probably unnecessary.. Also forgot to mention, I also set the default Movement animation to Walk_Static. Not sure if thats required though.
PS
7 months ago
Reply@Greta C (GretaACN)How did you do it? I'm trying to get mine to work and I'm not sure how to :(
@GretaACN Hi :) In the PlayerController script I added two variables public bool gameStart = false; public float walkingSpeed = 0.45f; I added gameStart to the jump statement if(Input.GetKeyDown(KeyCode.Space) && isOnGround && gameStart && !gameOver) And in both the MoveLeft and SpawnManager scripts I added it to this statement, so that the background and obstacles doesnt start to move until the Player is in position. if(playerControllerScript.gameOver == false && playerControllerScript.gameStart == true) Back in the PlayerController script i added this line in Start() playerAnim.SetFloat("Speed_f", walkingSpeed); And since the condition for walking is Speed_f less than 0.5 this should make the walk animation start. Then I added this statement //Move character from left to right at start of game if (!gameStart) { playerAnim.SetFloat("Speed_f", walkingSpeed); if (transform.position.x < 0) { transform.Translate(Vector3.forward * Time.deltaTime * walkingSpeed * 3); } else { gameStart = true; walkingSpeed = 1; playerAnim.SetFloat("Speed_f", walkingSpeed); } } I hope this helps :)
G(
7 months ago
How did you do it? I'm trying to get mine to work and I'm not sure how to :(
About Me
No description
See more
Skills
No skills added yet
Certifications (0)
Import
See all
Patrick Simonsen's liked projects (8)
Following (0)
Not following anyone yet
Followers (0)
No followers
Following Companies (0)
Not following anyone yet