Ik heb dit project samen met 2 andere dev gedaan we hadden 4 weken ervoor om dit project te maken
Ghost AR/VR project waarmee je in de echte wereld kon zien en spelen. Het was vooral bedoeld om geesten te schieten, een beetje zoals een arcade game.
De schiet mechanic was met een bullet die uit de loop kom en de kogel heeft zelf een soort trace erbij zodat je ziet of je de target raakt
// Called when the fire input action is triggered
public void OnFire(InputAction.CallbackContext context)
{
isFiring = context.phase == InputActionPhase.Performed;
}
// Called when the grip input action is triggered
public void OnGrip(InputAction.CallbackContext context)
{
if (context.phase == InputActionPhase.Performed)
{
AlignToForward();
}
}
void Update()
{
if (isFiring && Time.time >= nextFireTime)
{
Shoot();
nextFireTime = Time.time + fireRate;
}
}
void Shoot()
{
GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
Rigidbody rb = bullet.GetComponent();
if (rb != null)
{
rb.linearVelocity = firePoint.forward * bulletSpeed;
}
}