3D On-rail shooter aiming system

TobyMoby

Member
Hi guys!

I have recently thought about programming a on-rail shooter type of game.
But one thing that is giving me headaches is the aiming system. I just can't put my head around it.

Has anyone on this forum some idea how something like this might work?
With a standard FPS aiming is "no problem", because the target is always the center of the field of view.
But it seems a little more tricky to translate the 2D crosshair from the screens rectangle to the environment.

I'm open for crazy ideas how one could make this possible, so please, shoot!

Best regards, Toby
 
B

Bayesian

Guest
But it seems a little more tricky to translate the 2D crosshair from the screens rectangle to the environment.
This is trivial to do in GMS compared to something like Unity

Code:
if(mouse_check_button_pressed(mb_left)){
    with(instance_create_layer(x,y,layer,oBullet)){
        var dir = point_direction(other.x,other.y,mouse_x,mouse_y)
        velocityx = lengthdir_x(bulletSpeed,dir)
        velocityy = lengthdir_y(bulletSpeed,dir)
    }
}
Fist we check if the left mouse button is pressed
instance_create_layer makes a new oBullet instance and also returns that specific instance's ID
This ID is used by with to apply what we put inside the with's {} to that specific object.
Then we get the direction of the mouse's position compared to the instance that called the with statement by using the key word other on its x and y
then we set the velocity of the bullet's x/y axes by using lengthdir which converts a length and a direction into the distance it should move per axis
In our case the distance is equal to the speed.

all you need to do now is have oBullet check for collisions based on its velocity.
 
Last edited by a moderator:
Top