playMaker

Author Topic: Aiming Routine Help  (Read 1047 times)

cmonroy

  • Playmaker Newbie
  • *
  • Posts: 34
    • View Profile
Aiming Routine Help
« on: May 12, 2014, 05:04:46 AM »
Hello to all.

I have a setup in which the camera always follows my character from behind and I need it to aim to where the cursor or reticle is located. All the aiming routines I've checked, assume the target will be at the center of the screen or rotate the character to compensate this. The character is a GameObject which contains the mesh and the camera, along the FSM's to control its locomotion. I've set the main camera the get its position and the coordinates of the mouse at the X and Y axes. I've even made it to calculate the Screen to World Points and store its World vector, but I'm not really sure how to proceed.

Any advice will be greatly appreciated.

Thank you.

cmonroy

  • Playmaker Newbie
  • *
  • Posts: 34
    • View Profile
[SOLVED] Re: Aiming Routine Help
« Reply #1 on: May 14, 2014, 05:22:26 PM »
It is simple, really.

MousePick only works when there is an object at the pointed location, but no when there is no geometry at the designated vector. So, I built a room with walls and ceiling, put a little sphere (which works as my aiming point)  and used an FSM with a MousePick and a Set Position actions. A previous event set the cursor to a reticle and voilĂ : it worked...

Now, this solution will not work in open spaces unless you can provide some bounding planes at the edges of your level and increase accordingly the ray distance.

From here, making a raycast to the aiming point is easy. Hope this serves anyone having similar issues.