September 19, 2019, 12:30:49 PM

Author Topic: Any suggestions?  (Read 2374 times)

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Any suggestions?
« on: August 30, 2017, 08:24:52 PM »

I have a very strange effect on my character controller.  :'(


Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 774
Re: Any suggestions?
« Reply #1 on: August 30, 2017, 10:22:48 PM »
Perhaps the endless fall should be limited to certain depth to avoid the artefacts.

I've seen the same when my player was not on an object and just fell into the deep void.
Or when got too high.

Perhaps it's got to do with the camera range setting?
_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: Any suggestions?
« Reply #2 on: August 30, 2017, 10:29:23 PM »
Code: [Select]
SetObjectPosition ( jugador.pivote, GetObjectX(jugador.malla),GetObjectY(jugador.malla) ,GetObjectZ(jugador.malla) )

I'm just trying to position the player's pivot on the model of the capsule which is a controller character.




Code: [Select]

// Bucle Principal.
While GetRawKeyReleased ( Key.Escape ) = 0





Print( ScreenFPS() )







ActualizarCamara( jugador )

RotarPivote( jugador )
Move3DPhysicsCharacterController( jugador.malla,1, 10 )
Step3DPhysicsWorld()
SetObjectPosition ( jugador.pivote, GetObjectX(jugador.malla),GetObjectY(jugador.malla) ,GetObjectZ(jugador.malla) )
Sync()


EndWhile

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: Any suggestions?
« Reply #3 on: August 30, 2017, 11:31:27 PM »

Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 774
Re: Any suggestions?
« Reply #4 on: August 30, 2017, 11:45:37 PM »
Whoha! You have been quite busy!  :o

I'm still trying to create a suitable 'regular'  1st & 3rd person controller and you already moved onto physics controller. I'm not there yet.


In in the video I see your camera follows the player.
In the code you shared the camera does *not* follow the player.

I see you are using types, functions and includes a lot, which is great for a final version, but could also loose track like that.

For trying out stuff I would first use a very crude and simple approach as a prototype.
If it then works, move on to more complex constructions.

-Keep it simple until concept proven to work?

 
_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 774
Re: Any suggestions?
« Reply #5 on: August 31, 2017, 12:27:36 AM »
I didn't go through the entire code to analyze what happens, for I'm not at all that familiar with the physics usage yet, but I see you use:

SetObjectPosition ( jugador.pivote, GetObjectX(jugador.malla),GetObjectY(jugador.malla) ,GetObjectZ(jugador.malla) )

while there is also a command:

Set3DPhysicsCharacterControllerPosition( objID, posX, posY, posZ )

Is this intentional?


_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: Any suggestions?
« Reply #6 on: August 31, 2017, 12:50:15 AM »
Hi, update link dropbox. Camera fix on player move.


The drawback is that using the system to position the pivot on the controller of the player, you see the rare effect that the capsule jumps forward and backward when the player moves. I have no idea how to solve this.


Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: Any suggestions?
« Reply #7 on: August 31, 2017, 12:56:07 AM »
Code: [Select]
// Update Pos Camara on Pivot.
Function ActualizarCamara( jugador As TJugador)




// Here pos Camara on child cube.
SetCameraPosition( 1, GetObjectWorldX( jugador.camara),GetObjectWorldY( jugador.camara) ,GetObjectWorldZ( jugador.camara) )
SetCameraLookAt( 1, GetObjectX( jugador.pivote ), GetObjectY( jugador.pivote ), GetObjectZ( jugador.pivote ), 0 )


// Here pivot Father on Mesh Player.
SetObjectPosition ( jugador.pivote, GetObjectX(jugador.malla),GetObjectY(jugador.malla) ,GetObjectZ(jugador.malla) )


EndFunction



Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 774
Re: Any suggestions?
« Reply #8 on: August 31, 2017, 01:25:34 AM »
I see what you mean now. Hmm, strange indeed, but interesting. I'm not experienced in the physics thing though.

Question, do you:

A) move the physics capsule and then attach the  player mesh as child
or the other way round, like:
B) move the player mesh and then attach the physics capsule as child ?



Now need to go sleep though, 2:18 AM here..  :o  Boss is not gonna be happy if late(again).  ::)


_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: Any suggestions?
« Reply #9 on: August 31, 2017, 02:42:56 AM »

I do not find solution to this, the capsule is a mesh of which is established with the controller of the characters of the system of bullet physics.


I am only working, on Sundays 24 hours, Tuesdays 12 hours and Friday 12 hours. The boss under the work and that has me worried, because he did not win much and now less.


Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 774
Re: Any suggestions?
« Reply #10 on: August 31, 2017, 01:32:45 PM »
Don't know if you already have these but on the AGK forums there are a couple of physics examples, see here:
https://forum.thegamecreators.com/thread/216683?page=1

Basic World Setup.zip   
Manipulating Physics Bodies.zip   
Contact Reports.zip   
Joints.zip   
Raycasting.zip   
CharacterControllerRagdoll.zip   << Nice stuff, but cam not linked to player though.


So I added this 1 line:

Global maskedSoldier   // <<< Added for follow cam.

right above the line in main.agc that reads:
maskedSoldier = LoadObjectWithChildren( "/media/Masked Soldier Frag.x" )


And then use below.
Code: [Select]
function FreeFlightCameraUsingMouseAndArrowKeys(  cameraID as integer, speed as float)
if GetMouseExists() and lockMouse = 0
rawMouseX = 0.0
rawMouseY = 0.0
if mouseSet = 1
rawMouseX = ( GetDeviceWidth() / 2 ) -  GetRawMouseX()
rawMouseY = ( GetDeviceHeight() / 2 ) -  GetRawMouseY()
oldCamAngleX = cameraAngleX
oldCamAngleY = cameraAngleY
cameraAngleY = WrapAngle( cameraAngleY - rawMouseX * 0.2)
cameraAngleX = WrapAngle( cameraAngleX - rawMouseY * 0.2)
if cameraAngleX <= 290.0 and cameraAngleX > 180.0  then cameraAngleX = 290.0
if cameraAngleX >= 70.0 and cameraAngleX < 180.0 then cameraAngleX = 70.0
cameraAngleX = CurveAngle( cameraAngleX, oldCamAngleX, speed  )
cameraAngleY = CurveAngle( cameraAngleY, oldCamAngleY, speed  )
endif
SetRawMousePosition( GetDeviceWidth() / 2, GetDeviceHeight() / 2 )
//SetRawMouseVisible does not work correctly bug in AGK
//SetRawMouseVisible( 0 )
mouseSet = 1
endif
SetCameraRotation( cameraID, cameraAngleX, cameraAngleY, 0.0 )
if GetRawKeyReleased( 27 )
lockMouse = lockMouse + 1
if lockMouse = 2 then lockMouse = 0
if GetMouseExists()  and lockMouse = 1
//SetRawMouseVisible does not work correctly bug in AGK
//SetRawMouseVisible(1)
mouseSet = 0
endif
endif
if GetKeyboardExists()
if GetRawKeyState( 37 )  then MoveCameraLocalX( cameraID, -1.0 * speed )
if GetRawKeyState( 39 ) then MoveCameraLocalX( cameraID, 1.0 * speed )
if GetRawKeyState( 38 ) then MoveCameraLocalZ( cameraID, 1.0 * speed )
if GetRawKeyState( 40 ) then MoveCameraLocalZ( cameraID, -1.0 * speed )
endif

// ################## Rick's additions (just a quick fix) :-)  ####################
// set camera on your character
    SetCameraPosition(1, GetObjectX(maskedSoldier),GetObjectY(maskedSoldier),GetObjectZ(maskedSoldier))
//align camera rotation with character POV
    SetCameraRotation( 1, 0,GetObjectAngleY(maskedSoldier)-180 , 0)
//move the camera behind you
    MoveCameraLocalZ(1, -44)
//move the camera up
    MoveCameraLocalY( 1, 75 )
// ################################################################

endfunction

Hope this helps. But I do notice a little stutter, even so quite workable.

_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: Any suggestions?
« Reply #11 on: August 31, 2017, 06:31:24 PM »

Hello, this is improving a bit, at least since I know that there is the command movecamera, always something to learn ... it seems like I'm caught in an infinite learning cycle and will never make a game. :'(



The case is that of both moving one thing and another there, this improved drastically, it seems that some elves last night were on my pc giving a little help, but not completely, because now the command SetCameraLookAt, does not work. But here goes the video ....

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: Any suggestions?
« Reply #12 on: August 31, 2017, 06:35:13 PM »


Something happened last night, I do not know what it was ...

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Re: Any suggestions?
« Reply #13 on: August 31, 2017, 06:46:38 PM »
Eureka!!  :D



:) :) :)


Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 1999
Re: Any suggestions?
« Reply #14 on: August 31, 2017, 06:52:04 PM »
 ;D

Glad you're making (rapid) progress Yue.
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.1, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspbian Buster, pi4 4Gb RAM,1.5Ghz