HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.
Pages: 1 [2] 3

Author Topic: [Resolved] Shoulder Camera Examples (Code Provided)  (Read 9442 times)

DragonFist

  • General Accounts
  • *
  • Posts: 140
    • View Profile
Re: Shoulder Camera Examples (Code Provided)
« Reply #15 on: Aug 09, 12, 02:40:18 AM »

Sorry for late reply, I didn't see the earlier post.  Did you guys also change this to match whatever it is in the E_ version?

Code: [Select]
   
    if cam is kindof ADV_LerpCamera
      cam.ADV_DragRotateCamera(cam,fy,fx,0)
    else
      RotateNode(cam,fy,fx,0)
Logged

MageRage

  • World Owners
  • ****
  • Posts: 3
    • View Profile
Re: Shoulder Camera Examples (Code Provided)
« Reply #16 on: Aug 09, 12, 04:17:37 PM »

Sorry for late reply, I didn't see the earlier post.  Did you guys also change this to match whatever it is in the E_ version?

Code: [Select]
   
    if cam is kindof ADV_LerpCamera
      cam.ADV_DragRotateCamera(cam,fy,fx,0)
    else
      RotateNode(cam,fy,fx,0)

Yes all ADV_ references were changed to E_ as it wouldnt let me compile without it as we dont have any ADV_ in our scripts. I looked at all the E_LerpCamera and compared to the ADV_LerpCamera that was on the wiki and it was the exact same. So I dont know why the mouse look while in first person wont update the direction they start running.

I also tried the FPS Tutorial right from the wiki and had the same problem.

Logged

DragonFist

  • General Accounts
  • *
  • Posts: 140
    • View Profile
Re: Shoulder Camera Examples (Code Provided)
« Reply #17 on: Aug 09, 12, 05:23:37 PM »

Throw a println into the OnMouseMove().  This should be happening here, make sure the event handler is being hit.  Also make sure that you have the toggle mouse lock stuff set as needed.

Another place to look is in the method _HE_ACCC_NavigateLocal() method of E_ACCControllerClassMethods.

Also, take a look at the last post of this thread on the First Person Camera when I had similar issue:

https://community.heroengine.com/forums/index.php/topic,2613.msg16376.html#msg16376
« Last Edit: Aug 09, 12, 05:34:29 PM by DragonFist »
Logged

Triplelexx

  • World Owners
  • ****
  • Posts: 23
    • View Profile
Re: Shoulder Camera Examples (Code Provided)
« Reply #18 on: Aug 10, 12, 02:43:05 AM »

Thanks, got it fixed it now.

The problem was with the HE_ACCC_NavigateLocal() method.
It's defining cam as "GAME" before it does the character rotation so will not do it when we swap to "FP_Camera".

I've added a check to see if we're in FPS mode and then I set cam = AddCamera("FP_Camera"), or back to "GAME" if not.

I've got to start over with a lot of this again now but this still helps a lot.

Thanks again!
« Last Edit: Aug 10, 12, 02:49:04 AM by Triplelexx »
Logged

MageRage

  • World Owners
  • ****
  • Posts: 3
    • View Profile
Re: Shoulder Camera Examples (Code Provided)
« Reply #19 on: Aug 11, 12, 10:15:41 PM »

Thanks, got it fixed it now.

The problem was with the HE_ACCC_NavigateLocal() method.
It's defining cam as "GAME" before it does the character rotation so will not do it when we swap to "FP_Camera".

I've added a check to see if we're in FPS mode and then I set cam = AddCamera("FP_Camera"), or back to "GAME" if not.

I've got to start over with a lot of this again now but this still helps a lot.

Thanks again!

Yup that fixed it.

Alright anyone else having this problem look in E_ACCControllerClassMethods and around line 1394 you will see
cam as NodeRef of Class HBNode = AddCamera("GAME"). This is causing it only to judge your position based on the Camera named GAME not your FP_Camera (first person camera).

I replaced it with this:

Code: [Select]
        actvcam as NodeRef = getActiveCamera()
       
        if actvcam["CameraName"] != "GAME"
          actvcam = AddCamera("FP_Camera")
         else
         actvcam = AddCamera("GAME")
         .
                   
       
        cam as NodeRef of Class HBNode = actvcam       

And now it checks what the active camera is and sets the node now to that. Now I can go between 3rd person and first person and be able to move the camera with my mouse and it update based on which direction I am facing.


Thanks for the help DragonFist.


Logged

AndrewE

  • General Accounts
  • *
  • Posts: 4
    • View Profile
Re: Shoulder Camera Examples (Code Provided)
« Reply #20 on: Sep 08, 12, 12:55:35 AM »

Looking at your videos of the over the shoulder angle, it looks like your camera is relatively level with your character's head. Is that just a combination of the character stance along with the 22 degree rotation? The code seems to just move the camera left or right and then rotate the character by 22 degrees. I'm not seeing anywhere that raises/lowers the camera to be higher/lower than the character's mid-back. Am I missing something?

I'm looking for a way to raise the camera so it's level with the head (or even higher than the head), but I can only find the SetHorizontalCenterOffset function to move it left/right of the character. I would think there would be a SetVerticalCenterOffset function, but there doesn't seem to be one.

Does anyone know how I can raise/lower the camera? I appreciate any help.

Thanks!
Andrew
Logged

DragonFist

  • General Accounts
  • *
  • Posts: 140
    • View Profile
Re: Shoulder Camera Examples (Code Provided)
« Reply #21 on: Sep 08, 12, 01:33:54 AM »

From the wiki:

 Set Camera Follow Offset

SetCameraFollowOffset(name as string, offset as vector3)

Sets the follow offset on the specified camera, meaning the position that the camera is attached to the character (such as the back of the head, or whichever point on the character the camera goes to if it zooms in all the way). For example, the "position" of the character is the position where the character's feet are, and the offset would be the vector3 from the feet to the head.
Logged

AndrewE

  • General Accounts
  • *
  • Posts: 4
    • View Profile
Re: Shoulder Camera Examples (Code Provided)
« Reply #22 on: Sep 08, 12, 10:45:24 AM »

Wow. How embarrassing. I looked at camera functions page twice before posting and totally missed that function.
Thank you very much!
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1154
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: [Resolved] Shoulder Camera Examples (Code Provided)
« Reply #23 on: Jan 04, 13, 11:10:12 PM »

Nice tutorial, thanks.

Checking for which camera was active helped the 1st person view moving forward with actcam.

I noticed that when I stopped moving and used the wheel to move from 1st person back to 3rd person, the camera would switch back to the other camera view, which might have been facing another direction.

I am looking into setting the rotation of the 3rd person camera view based on the 1st person camera view when switching back. It might be something like making the 3rd person camera follow to keep the same view angle.
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1154
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: [Resolved] Shoulder Camera Examples (Code Provided)
« Reply #24 on: Jan 05, 13, 12:36:32 AM »

I have found that by making 1 camera of the 2 and just checking for which we should be displaying, we can use less code. I have modified the code a little, and did not use the over the shoulder for this camera. It is pretty basic mouse wheel 1st and 3rd person camera. This mod does not need the addition in E_ACCControllerClassMethods, and has lerp removed. The only downside is the player's weapon still showing.

Code: [Select]
function OnMouseMove(mx as Integer, my as Integer, dx copies Integer, dy copies Integer) as Boolean

  if (GetCmdState("Camera","DragRotate"))
    cam as NodeRef = GetActiveCamera()
    if (GetTweakableBoolean("GameInvertMouseX")) or $INPUT._InputGameInvertMouseX
      dx = dx * -1
    .
    if (not GetTweakableBoolean("GameInvertMouseY")) and ( not $INPUT._InputGameInvertMouseY )
      dy = dy * -1
    .
   
    fx as Float = dx
    fy as Float = dy
    if $INPUT._InputGameMouseSensitivity > 0
//      dx = round( dx * $INPUT._InputGameMouseSensitivity )
//      dy = round( dy * $INPUT._InputGameMouseSensitivity )
      fx = fx * $INPUT._InputGameMouseSensitivity
      fy = fy * $INPUT._InputGameMouseSensitivity
    .
   
    RotateNode(cam,fy,fx,0)
   
    return true
  else if (GetCmdState("Camera","DragRotateCamera"))
    SetCmdState("Camera","DragRotateCameraEngaged",true)
    cam as NodeRef = GetActiveCamera()
    if (GetTweakableBoolean("GameInvertMouseX")) or $INPUT._InputGameInvertMouseX
      dx = dx * -1
    .
    if (not GetTweakableBoolean("GameInvertMouseY")) and ( not $INPUT._InputGameInvertMouseY )
      dy = dy * -1
    .
   
    fx as Float = dx
    fy as Float = dy
   
    if $INPUT._InputGameMouseSensitivity > 0
//      dx = round( dx * $INPUT._InputGameMouseSensitivity )
//      dy = round( dy * $INPUT._InputGameMouseSensitivity )
      fx = fx * $INPUT._InputGameMouseSensitivity
      fy = fy * $INPUT._InputGameMouseSensitivity
    .
   
    playerCharacter as NodeRef of Class HBNode = GetPlayerCharacterNode()
    if playerCharacter <> None
      ACCController as NodeRef of Class _ACCController
      ro as Vector3
     
      where playerCharacter is kindof _ACCControllerOwner
        ACCController = playercharacter._getACCController()

        if ACCController <> None
          ro.y = ACCController._getGameCameraRotationalOffset().y + dx
          ACCController._setGameCameraRotationalOffset(ro)
        .
      .     
    .
   
    RotateNode(cam,fy,fx,0)

    return true 
  .

  return false
.

function SetupFP_Camera()
  character as NodeRef = GetPlayerCharacterNode()
  character["Render"] = false
  SetCameraOffset("*",0.0)

  if character <> None
      ACCController as NodeRef of Class _ACCController
      ro as Vector3
     
      where character is kindof _ACCControllerOwner
        ACCController = character._getACCController()

        if ACCController <> None
          ro.y = 0
          ACCController._setGameCameraRotationalOffset(ro)
        .
      .     
    .

  FreeLook( "FP_Camera", true )
  SetCmdState("Camera","FirstPersonCameraEngaged",true)
.

function SetupOS_Camera()
  character as NodeRef of Class HBNode = GetPlayerCharacterNode()
  character["Render"] = true

  gco as Float = GetCameraOffset("*")
  if (gco > 1.5)
    gco = 1.5
  .
  SetCameraOffset("*",gco)

  FreeLook( "GAME", false )
  SetCmdState("Camera","FirstPersonCameraEngaged",false)
.

function OnMouseWheel(delta as Integer) as Boolean

// Used to determine the offset to use for the camera
//
  w as Float = delta * .0008
  gco as Float = GetCameraOffset("*")

  gco = gco + w
  if (gco > 1.5)
    gco = 1.5
  .

  cam as NodeRef = GetActiveCamera()
  SetCameraOffset("*",gco)

  if ((gco >= 0.06))        // check for 3rd person
    SetupOS_Camera()
  .

  if ((gco < 0.06))          // check for 1st person
    SetupFP_Camera()
  .

  return true
.

function onCmdStart(cmd as String) as Boolean
  if (cmd=="DragRotate" or cmd=="DragRotateCamera")
    if GetCmdState("Camera", "DragRotateCameraEngaged")
      SetCmdState("Camera","DragRotateCameraEngaged",false)
      playerCharacter as NodeRef of Class HBNode = GetPlayerCharacterNode()
      if playerCharacter <> None
        ACCController as NodeRef of Class _ACCController
        ro as Vector3
       
        where playerCharacter is kindof _ACCControllerOwner
          ACCController = playercharacter._getACCController()
 
          if ACCController <> None
            ro.y = ACCController._getGameCameraRotationalOffset().y
            ACCController._clearGameCameraRotationalOffset()
          .
        .
        cam as NodeRef = GetActiveCamera()
        RotateNode(cam,0,-ro.y,0)
      .
    .
    if $PLAYMODE._getPlayModeState() == ON
      $Cursor._setCustomCursorVisibility(false)
    else
      SetCursorVisibility(false)
    .
   
    return true
  .

  if (cmd=="ToggleFullscreen")
    SYSTEM.EXEC.CPULIMIT = 0:00:30
    NotifyStateChange("TOGGLE_FULLSCREEN")
    return true
  .
  if (cmd=="ClearRotateCamera")
    playerCharacter as NodeRef of Class HBNode = GetPlayerCharacterNode()
    if playerCharacter <> None
      ACCController as NodeRef of Class _ACCController
      ro as Vector3
     
      where playerCharacter is kindof _ACCControllerOwner
        ACCController = playercharacter._getACCController()

        if ACCController <> None
          ro.y = ACCController._getGameCameraRotationalOffset().y
          ACCController._clearGameCameraRotationalOffset()
        .
      .
      cam as NodeRef = GetActiveCamera()
      RotateNode(cam,0,-ro.y,0)
    .
    return true
  .
  if (cmd=="ToggleAspectRatio")
    NotifyStateChange("TOGGLE_ASPECTRATIO")
    return true
  .
  if (cmd=="RotateCameraUp" or cmd=="RotateCameraDown" or cmd=="ZoomIn" or cmd=="ZoomOut")
    return true
  .
  if (cmd=="Click")
    return false   
  .
  return false
.


function onCmdStop(cmd as String) as Boolean
  if (cmd=="DragRotate" or cmd=="DragRotateCamera")
    cam as NodeRef = GetActiveCamera()

    if $PLAYMODE._getPlayModeState() == ON
      $Cursor._setCustomCursorVisibility(true)
    else
      SetCursorVisibility(true)
    .
    SetIgnoreCursor(false)
    return true
  .

  if (cmd=="ToggleFullscreen" or cmd=="ClearRotateCamera" or cmd=="ToggleAspectRatio")
    return true
  .
  if (cmd=="RotateCameraUp" or cmd=="RotateCameraDown" or cmd=="ZoomIn" or cmd=="ZoomOut")
    return true
  .
  if (cmd=="Click")
    return false
  .
  return false
.

function onFrameUpdate(elap as TimeInterval)

  if (GetCmdState("Camera","RotateCameraUp"))
    dX as Float = .12 * elap.millisecondsTotal
    cam as NodeRef = GetActiveCamera()
    RotateNode(cam,dX,0,0)

  else if (GetCmdState("Camera","RotateCameraDown"))
    dX as Float = -.12 * elap.millisecondsTotal
    cam as NodeRef = GetActiveCamera()
    RotateNode(cam,dX,0,0)

  else if (GetCmdState("Camera","ZoomIn"))
    w as Float = elap.millisecondsTotal * .0007
    gco as Float = GetCameraOffset("*")
    gco = gco - w
    if (gco > 1.5)
      gco = 1.5
    .
    SetCameraOffset("*",gco)

  else if (GetCmdState("Camera","ZoomOut"))
    w as Float = elap.millisecondsTotal * .0007
    gco as Float = GetCameraOffset("*")
    gco = gco + w
    if (gco > 1.5)
      gco = 1.5
    .
    SetCameraOffset("*",gco)

  .
.

« Last Edit: Jan 06, 13, 01:17:58 AM by Thazager »
Logged

Studio_Unlimited

  • World Owners
  • ****
  • Posts: 18
    • View Profile
Re: [Resolved] Shoulder Camera Examples (Code Provided)
« Reply #25 on: Jan 15, 13, 10:23:07 AM »

I implemented this code to try but I am not sure how to activate the camera, is there a line for console like on the FPS Tutorial?
Logged

PN-Dwight

  • General Accounts
  • *
  • Posts: 465
    • View Profile
    • Pirates' Nest
Re: [Resolved] Shoulder Camera Examples (Code Provided)
« Reply #26 on: Jan 15, 13, 10:57:08 AM »

I implemented this code to try but I am not sure how to activate the camera, is there a line for console like on the FPS Tutorial?

Did you compile and submit your code? This was your issue last time.

Studio_Unlimited

  • World Owners
  • ****
  • Posts: 18
    • View Profile
Re: [Resolved] Shoulder Camera Examples (Code Provided)
« Reply #27 on: Jan 16, 13, 11:32:10 AM »

Yeah, compiled and submitted - everything ok.

there was the issue with having to change ADV_ to E_ in the script for it to compile, so that is working.

just no change in camera, is there a console command like in fps reference similiar to

call fps_camera_callback startfps_camera ?
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1154
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: [Resolved] Shoulder Camera Examples (Code Provided)
« Reply #28 on: Jan 16, 13, 02:26:32 PM »

If you are using the original tutorial, there is a few things to add in the keybindings.ini file, for the user input.

If you are using the mod I made, you can just use the mouse wheel to scroll into the 1st person view.
Logged

byberg

  • General Accounts
  • *
  • Posts: 63
    • View Profile
Re: [Resolved] Shoulder Camera Examples (Code Provided)
« Reply #29 on: Mar 31, 13, 03:49:25 PM »

Great tutorial.

Is there anyway to be able to rotate the camera on click with mouse cursor visible?
Logged
Pages: 1 [2] 3