Hi,
I need a camera behind a player and I want this camera move with the player, but not going through environment or other players.
Environment and players are rigid bodies.
How can I do that ? A blend example would be nice
Thanks
Hi,
I need a camera behind a player and I want this camera move with the player, but not going through environment or other players.
Environment and players are rigid bodies.
How can I do that ? A blend example would be nice
Thanks
Simple enough trick would be to attach small transparent plane diagonally to camera and enable rigidbody for it.
Hi,
thanks for your answer, but I canât understand how it would workâŚ
Is the plane a child of the camera ? I know that you can hide the plane in the visibility section :
The camera has to be ideally placed behind the player, and move with it, so should the camera be a child of the player ?
How will the camera return at this place after a collision with a rigid body ?
Iâm still searching, but I canât currently find a solutionâŚ
Hi @mokauno,
One way I tried is this:
I tried to achieve this using nodes only, but it seems the translate on local axis node does not respond as needed. Anyways, here is the blend file I tried.
NoWallHit.blend (1.2 MB)
Hope this helps.
Best regards,
QC
Hi QC,
thanks for your effort, Iâm amazed you provided a so hardworking answer.
I was thinking about something similar, but it was too much confuse for me to manage the problem.
The camera reaction on your example is weird, but itâs a good start point, and I will work on it.
Be sure I will share the final solution if I get one.
BTW, i always had problems with moving cameras along local axis. I believe cameras have a different coordinate system, note sure, but camera is facing -Z and thatâs not for helping us. The solution I usually use is to parent the camera to an empty (that has good coordinates) and apply local transform to this parent.
I added a cone to the child of the camera to make it easier to understand the state of the camera, and tried to shoot with another camera.
NoWallHit2.blend (1.3 MB)
But it is not perfect yet.
Hi @Sandy,
Thank you for the suggestions.
The only real issue I am stuck with is the moving on local axis when parented. As you stated in (2.), setting the value in x axis moves in local z direction. But if I then rotate the player and try again, it does not move on its local axis anymore.
It is this issue that I am referring to. And it needs to be fixed ASAP. The workaround posted by @Simonrazer in that thread also does not work.
Best regards,
QC
Same problems for me, canât find a solution in this way.
So, does the camera really needs to be parented ? It could live itâs own life, always tracking the player with the âlook atâ node, then adjusting the distance with a ray cast just like in the solution of QC âŚ
There could also be an empty parented to the player that represent the camera location if there is no obstacle. Then the camera could, on update, target this locationâŚ
The next problem would be that the âup of the cameraâ and the âup the the playerâ will have to point the same direction (stay on the same plane ?), especially if the player is a space shipâŚ
Hello again,
So I just did a quick Haxe code for the thing. It now works much better. Please try and let me know:
Blend file:
NoWallHit3.blend (1.3 MB)
Haxe trait: (Place in /Sources/arm/
)
CameraBmberHaxe.hx (1.3 KB)
Best regards,
QC
Iâm really sorry I canât get it work. The console says :
Trace: TypeError: Cannot read property âtransformâ of null
at Array. (:380:27)
at iron_App.update (:2532:27)
at kha_TimeTask.task (:25940:3)
at Function.kha_Scheduler.executeTimeTasks (:25824:75)
at Function.kha_Scheduler.executeFrame (:25776:17)
at kha_SystemImpl.renderCallback (:26579:16)
Interestingly enough, it works on my end when I re-downloaded the .blend and .hx it into a new folder.
The haxe trait CameraBmberHaxe.hx
must be applied to the empty
parented to the player
object and not the camera
.
The Player
object must have just one trait enabled: PlayerContol
No other trait must be applied to any other objects.
Let me know if this helps.
Well, I got exactly the same error after deleting everything and downloading again, and checkingâŚ
Surely something on my system is wrong⌠I looked at your source code, it seems very similar to your previous node setup. Did you change something essential ?
If someone get this working, please tellâŚ
I commented the section notifyOnUpdate, and got no error, so itâs thereâŚ
I get the error on : hit = physics.rayCast(player.transform.world.getLoc(), planeFront.transform.world.getLoc());
is there a tryâŚcatch to apply on this code ?
Did you re-download the new blend file?
Not sure what could be wrong, but here is a zip file for the same.
Download the zip file as a whole, simply unzip, open the blend file and run. Please try and let me know.
Zip did the same error. I think physics.rayCast returns null and throw an exception. I donât know why it works on your system, but you may you need to add a âtry catchâ on your code to catch the exception⌠Or maybe I need to update my systemâŚ
physics.rayCast
should not return an error unless the objects player
and planeFront
donât exist in the scene. I am totally lost now.
Let get a rest man.
I think we focused too much of having a camera parented to the player, I will work at an other approach where the camera is free from the player.
If you get something on your way, let us know. Youâre a boss.
Thanks
Mokauno.
For me the code you write works perfectly. Using this code to modify the âTranslate Objectâ and âTranslate On Local Axisâ nodes seems to solve the logic node problem as well.
Yes ! The haxe version works very well
Iâm sorry, i needed to update Armory SDK to get it working.
QC and Sandy, your help was really useful, thanks !
I adapted QCâs work to have it working with logic nodes only, and without additional planes.
Itâs also relative to the parent.
Here is it : NoWallHit_nodes.blend (1.3 MB)
Have a nice day