playMaker

Author Topic: Camera and wall help [SOLVED]  (Read 5558 times)

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Camera and wall help [SOLVED]
« on: December 12, 2013, 04:46:30 PM »
Hi, i am using an empty look at target this has the character controller and a child plane as my character.

A GO_Camera parent and the main camera as the child.

The camera follows the player the camera position 0.0, 0.1, -3.2.

When moving the camera to zoom in.

I need the camera to move to self 0.0, 0.0, 0.0.

I am using Itween move to.

Currently using the "Q" key.

This work great the camera zooms into the position,

My issue is i want to move the camera to this position at stages based on is the wall still in the way.


So maybe using a ray cast from the camera is the wall in the way, yes move the camera, but not all the way, just move in enough so the wall is no longer in the way.

The camera must stop at 0,0,0, this will mean the player is against the wall.

Now the player moves away from the wall i want the camera to move backwards to the max of 0.0, 0.1, -3.2.

I can not see a way to do this without help.

As the plane always faces the camera and does not turn my problem is kinda unique.

I did try using collision zones but feel that ray casting is the correct way?






« Last Edit: December 16, 2013, 01:33:10 PM by colpolstudios »

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: Camera and wall help
« Reply #1 on: December 13, 2013, 12:08:40 PM »
small update:

after reading through some other posts i was able to add a box collider to the camera I had also to add rigid body to the go.camera parent and the camera.

The camera box collider is checked is trigger.

A new object wall testing object also has a box collider tag WALL.

The main camera has an FSM with trigger event checking for camera hit wall.

So i need to store the position of this wall there will be more than one.

Camera has hit the wall, move the camera forwards only until the wall is no longer in the way, stop moving the camera.

Continue doing this loop as long as the player moves towards the wall.

But now the player moves away from the wall i need to reverse the camera movement.

Maybe by checking the z axis of the player ??

Possibly I am going about this all wrong?









jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Camera and wall help
« Reply #2 on: December 15, 2013, 05:05:56 AM »
Hi,

 raycasting is the way to go. If you study and play the Unity demo "Stealth", there is a similar camera work, it works like this:

It has three different preseted camera height

it checks for the current height preset with a raycast, if a obstacle if found it moves to the next height preset.

if no obstacle is found on the current height, it checks for the previous height preset, and stay put if an obstacle if found, else lower to that preset and so forth.

Does that make sense?

bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: Camera and wall help
« Reply #3 on: December 15, 2013, 07:58:08 AM »
Is there a camera movement example but done using playmaker?

My c# coding skills are not good.

The stealth camera is very good but i want the camera to go through the wall and not change height.

Updated: https://dl.dropboxusercontent.com/u/150707256/sprite%20character/webplayer.html

I simply added a fsm to the stealth camera follow player.

Collision zones are used to switch between my own camera and the stealth camera.



« Last Edit: December 15, 2013, 12:13:11 PM by colpolstudios »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Camera and wall help
« Reply #4 on: December 16, 2013, 07:09:05 AM »
Hi,

 I am not sure I follow now, you say that you want the camera to go through the walls?  so can you explain a bit more about the point of your camera setup?

bye,

 Jean

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: Camera and wall help
« Reply #5 on: December 16, 2013, 01:32:39 PM »
hi Jean, I think i can work it out myself thanks to looking more closely at the stealth example camera setup.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Camera and wall help [SOLVED]
« Reply #6 on: December 16, 2013, 01:37:44 PM »
Hi,

Cool,

 Bye,

 Jean