mojo3d : Shooting item from camera (angle)

About Monkey 2 Forums Monkey 2 Programming Help mojo3d : Shooting item from camera (angle)

This topic contains 3 replies, has 4 voices, and was last updated by  DruggedBunny 1 year ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14106

    Pakz
    Participant

    I am trying to shoot an item but I can not seem to figure out how to shoot something from the direction of the camera. I remembered there being an example where there was some kind of shooting but I can not find it anymore.

    What I want to do is; when I press the mouse I want to check a certain distance ahead to see if there is a cube there in the chunk. If I have the world coordinates then I can find the position in the array and then remove or add a cube.

    #14118

    Mark Sibly
    Keymaster

    The ‘forward vector’ of the camera may help here:

    Local fv:Vec3f=camera.Basis.k

    (Yes, that’s kind of ugly! perhaps Forward:Vec3f property could be added as an extension?)

    This returns a normalized vector representing the direction the camera is facing. For example, if the camera is pointed directly up, this will return (0,1,0).

    Note than in addition to entity.Basis.k, Basis.i will give you an entity’s ‘right’ vector and Basis.j will give you an entity’s ‘up’ vector.

    #14121

    Ethernaut
    Participant

    Mark, “Forward”, “Right” and “Up” properties on entities would be very welcome (or at least just Forward), as it is a lot easier for people looking into this for the first time to understand. Matrices are a little daunting on a first look.

    Thanks!

    #14123

    DruggedBunny
    Participant

    Try example 3 here:

    mojo3d Physics Samples

    Ignore the physics, but look at the bullet spawning child/parent code, might be of use anyway.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.