+23

Help with FPS controller

SomeT 4 months ago updated 4 months ago 8

I have done this tutorial but I am trying to add stuff to it: https://www.youtube.com/watch?v=y-l4bn4NPdo I tried to convert the main camera to a parent object under section in my macro titled: Have Camera act as parent object but its making my controls go backwards and I can't work out how to fix it?

Additionally, I need some advice on how to achieve raycasting collisions for when I crouch in BOLT if anyone could advise on this also it would be greatly appreciated or another way so when I crouch going through an object and uncrouch whilst under the object my players head does not go through the object?

FirstPerson.asset

Bolt Version:
1.4.4
Unity Version:
2019.1.8f1
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

I can't recreate your inverses control problem.
Can you show us your hierarchy or upload your scene?

For your second question you could make an ceiling check via raycast like your ground check. Then you only allow standing up, when there is noting on top of your player.

Main.unity

Scene file attached. Please note it also has probuilder in it from the package manager inside unity.



https://gyazo.com/2c85e169986474c24b4a01aa95c43dd0

that is my hierarchy.

That makes sense on the crouching was thinking of doing a bool of sorts to achieve this?

okay
I think you have to explain to me what you want to achieve in the end and why you did it as it is now.
Why do you want your camera on the root level?

When the camera is a child of player like in the tutorial, everything works fine.




For crouching a bool would be the best option.
You could also use a Toggle Flow but I don't think that's the right choice for this flow machine.



Something different---


This is atm doing nothing. What do you had in mind with this branch?

So basically I did the crosshair as parent, as when I crouched with it as a child of player it would always resize it, so I made the crosshair a parent and this fixed that issue of it resizing when crouching. I was then advised on #bolt-beginner-help on discord by TowerCrow and I think someone else to always do everything as parent objects, this way its easier and faster to obtain the gameobject and run the code in bolt, I think thats what was said anyway... trying to look over messages and can't remember / make much sense of this. I think unless I can better describe why I am doing this, is reattach the main camera as a child object to the player, as it don't seem to be breaking anything, including the crouching, this still works as intended. 

I think figuring out how and why I am using a raycast is the best step forward, I usually look in the unity documentation for this, but I don't know exactly what I am looking from in the unity documentation respective of raycasts and what I am looking to achieve on the crouching?, from there I willl research how to apply a bool to such effect. 

The hide crosshair is working on mine, I am not sure why, but if I don't put a bool and tick the box it don't seem to work then, not sure why it was a bit of guess work to be honest.

At the end  there are a lot of ways how to do specific things in unity.
For the crosshair as example I would use unity GUI to keep it separate from the player.

For crouching that would be my approach: 



I done it like this, but I don't know if I got the variables wrong in some way or form? Attached this script to the player. Anyhow it does not seem to work. Perhaps you can send me your asset file of your approach?

That should work....

I updated the function in your scene.





I also added a new graph variable:
 

Main.unity

FirstPerson.asset


Now, when ctrl is released while the player is still in the tunnel the player will stand up as soon as the raycast allows it.
But when you release ctrl in the tunnel and press it again, the player will automatically stand up when exiting the tunnel.
To prevent that you can use as example the toggle flow node.

Thanks for this. I will give it a go some point this weekend.