playMaker

Author Topic: First person controller  (Read 2277 times)

Dmonty

  • Playmaker Newbie
  • *
  • Posts: 7
First person controller
« on: January 09, 2020, 10:11:56 PM »
Hi everyone,

I'm trying to research how to create a first person controller that can interact with objects using raycast. For example. When object (crate) is within distance and the player is looking at it, they can open it by clicking on it. I know that this would be some sort of mouse event, but how cant I setup the first person controller to do this. Here is an example of what I'm trying to do

Thank you,


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: First person controller
« Reply #1 on: January 14, 2020, 02:51:30 AM »
Hi,

where are you stuck at the moment?

- do you have a character controller to move around your scene like in this video?
- do you have a raycasting firing in the forward direction of the character?
- are you able to detect what's being hit by the raycast?
- are you able to check the distance of the hit?

if all that is true, you can then have an fsm that react in mouse down and check what's currently being hit, its distance and then decide what is the action to perform.

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: First person controller
« Reply #2 on: January 14, 2020, 03:18:17 AM »
Hi,

 downloaded the project and it's actually not that complex as it locks the mouse position in the center,

you can use MousePick action for example, you can also use your own raycast should you want to filter by tags ( mousepick only filters by layer)



let me know how it goes for you.

Bye,

 Jean

Dmonty

  • Playmaker Newbie
  • *
  • Posts: 7
Re: First person controller
« Reply #3 on: January 21, 2020, 02:09:23 PM »
Sorry for the delayed response! Thank you so much for this:) I'm going to create a character controller and try an set up everything the way suggested and will get back to you. Again, I'm really sorry for the delayed response.

-David

Dmonty

  • Playmaker Newbie
  • *
  • Posts: 7
Re: First person controller
« Reply #4 on: January 30, 2020, 01:17:36 PM »
Okay, I have set up the character controller using raycast and when an interactive object is hit the information is stored in a variable. The issue I'm is that when a raycast hits gameobject, it stops.

Here is what I'm trying to do

When  character is within a distance of interactive game object a gui will pop

When character is no longer looking at the object, gui disappears

Thank you,

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: First person controller
« Reply #5 on: February 06, 2020, 07:16:21 AM »
Hi,

Raycast gives you not just the gameobject hit but also the distance.

 What you could do is inform the hit object that it's hit by the raycast ( and also inform when it's not, like a mouse up and down event), and the object then check the distance to the player, and decide if it needs to show something or not

 if you understand the above, where is your struggle in implementing it?

Bye,

 Jean