Enemy projectiles shoot hit playership object and destory it(?) need someone with Microsoft Visual Studio #c inclined

Befejezett Kiadva: 4 évvel ezelőtt Kiszállításkor fizetve
Befejezett Kiszállításkor fizetve

Hi, I created a Unity game but I like to get the enemy projectiles to shoot and destroy player ship object. Finally, I want the health bar to increase when player ship objects shoots and hits or any enemy ship object or decrease when the enemy ship hits the player ship object.

[login to view URL]

using [login to view URL];

using [login to view URL];

using UnityEngine;

public class Projectiles : MonoBehaviour

{

public Transform playerShip;

public float range = 20.0f;

public float enemyGunImpulse = 10.0f;

bool onRange = false;

public Rigidbody projectile;

Rigidbody2D rigidbody2d;

void Start()

{

float rand = [login to view URL](1.0f, 2.0f);

InvokeRepeating("Shoot", 2, rand);

}

void Shoot()

{

if (onRange)

{

Rigidbody enemyGun = (Rigidbody)Instantiate(projectile, [login to view URL] + [login to view URL], [login to view URL]);

[login to view URL]([login to view URL] * enemyGunImpulse, [login to view URL]);

}

[login to view URL](GetInstanceID() + ": Shoot() called.");

[login to view URL]("Shoot Player!");

}

void Update()

{

onRange = [login to view URL]([login to view URL], [login to view URL]) < range;

if (onRange)

[login to view URL](playerShip);

}

}

[login to view URL]

using UnityEngine;

using [login to view URL];

using [login to view URL];

using System;

public class PlayerHealth : MonoBehaviour

{

[SerializeField] GameObject deathFX;

[SerializeField] Transform parent;

public Image Bar;

public Text Text;

public float max_health = 100f;

public float cur_health = 0f;

//Use this for initialization

void Start()

{

// Initialize the health that is given

cur_health = max_health;

InvokeRepeating("decreaseHealth", 0f, 2f);

}

void OnCollisionEnter(Collision collision)

{

if ([login to view URL]<Projectiles>())

{

max_health -= cur_health;

//if the collision object has a homing script, minus player health by damageToPlayer

}

}

void decreaseHealth()

{

//Subtract the health at the following rate

//Check if the health is 0 before we do any damage

if (cur_health < 0)

{

cur_health = 0;

}

//make a new variable and divide the current health my the maximum health

//this is because the fill value goes from 0 to 1

float calc_health = cur_health / max_health; // 70 / 100 = 0.7

SetHealth(calc_health);

//Change the color of the health bar

.NET C programozás C# programozás C++ Programozás Unity 3D

Projektazonosító: #19779511

A projektről

3 ajánlat Távolról teljesíthető projekt Utoljára aktív: 4 évvel ezelőtt

Odaítélve:

sunderplugs11

Hello! My name is Adam, I'm from WV, USA where I've been working in Unity full time for the last 3 years, with a good bit of time as a tutor. I can certainly help you rewrite your Projectile script and give you some Továbbiak

$15 USD 1 napon belül
(13 értékelés)
4.3

3 szabadúszó tett átlagosan 18$ összegű árajánlatot erre a munkára

abilalc1

Hello, I am a Full Stack Game Designer & Developer, I understand your requirements, and I can do the task in a reasonable amount of time. As you can see from my profile, I have done various projects, and all deliver Továbbiak

$20 USD 7 napon belül
(18 vélemény)
4.8
mariogavotto

Hi my name is Mario. im a game developer. I work with Unity and C#. I can help you to fix and implement your script in the game, Im ready to work now then talk to me in private to discuss more about your game Go Továbbiak

$20 USD 1 napon belül
(29 vélemény)
4.9