Hello, I am making a rail shooter, and want the space ship to aim at enemies that come towards the screen.
it would rotate the aiming on an axis point with the joystick,
I would want it to be only half a circle tho, so you can’t shoot behind yourself, only forward and sides. the ship will still move in 2D on a 2D plane with the other joystick, so aiming is separate from that.
here is a picture I made with blender that I hope helps to understand:
Hi @Psyball, I’m guessing U are already rotating your character/pawn using just yaw inputs. You can set limits to any/all the axes (roll, pitch, yaw) by adding a custom Player Camera Manager (set in Ur cusom Player Controller), so they can’t rotate backwards.
Here’s how I’d set up Ur character/pawn, bullet and enemy actors:
Character/pawn actor
put a ‘Scene’ component in Ur character/pawn at the point(s) where U’d like to shoot bullets from (the nose, wingtips, etc)
when your ‘Fire Weapon’ triggers:
— ‘Get Forward Vector’ (facing direction) of Ur spaceship
— ‘Get World Location’ of Ur scene component
— spawn the bullet actor, feeding in forward vector and location above
Bullet actor
maybe use a projectile actor which has convenient and efficient built-in functionality (incl. homing for missiles if U’d like to add special weapons)
set it’s travel speed in the component details
Enemy spaceship actor
set up collision
on the collision event, add logic to destroy itself, or reduce it’s health.
Later on, make the bullets and 'splosions look pretty by adding lights and particles.