Any suggestions?

Started by Yue, August 30, 2017, 20:24:52

Previous topic - Next topic

Yue


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

https://youtu.be/cc7yG61lYqI

Rick Nasher

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
_______________________________________

Yue

#2
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.

https://youtu.be/x7RuSLlxJao




// 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


Rick Nasher

#4
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
_______________________________________

Rick Nasher

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
_______________________________________

Yue

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.


Yue


// 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




Rick Nasher

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
_______________________________________

Yue


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.


Rick Nasher

#10
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.
https://www.youtube.com/watch?v=y1B6OzYVJGo

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.

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
_______________________________________

Yue


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 ....

Yue

https://youtu.be/MdCEX_6ZdBc

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


Steve Elliott

 ;D

Glad you're making (rapid) progress Yue.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb