playMaker

Author Topic: [Solved] Moving Camera with Player  (Read 2722 times)

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
[Solved] Moving Camera with Player
« on: November 22, 2018, 08:51:25 PM »
Hi !

My player has Smooth Look At Direction action. I want the camera to follow my player. But, camera shouldn't rotate. Only follow.
How can i do it ?


Thanks
« Last Edit: November 29, 2018, 05:13:19 AM by heavygunner »

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Moving Camera with Player
« Reply #1 on: November 23, 2018, 12:04:23 AM »
The reason your camera is shaking like that is because it is a child of the player so whenever the player moves, the child moves exactly the same.

What I'd do is break the camera from the player's child first.  Then throw a Smooth Follow Action onto the camera you wanna use.  After that set the target to your player and the rotation damping to 0 so it doesn't turn at all when the player moves.

I think that will be what you're looking for and its a pretty simple FSM to make which makes everything better :)

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Moving Camera with Player
« Reply #2 on: November 23, 2018, 01:22:52 PM »
The reason your camera is shaking like that is because it is a child of the player so whenever the player moves, the child moves exactly the same.

What I'd do is break the camera from the player's child first.  Then throw a Smooth Follow Action onto the camera you wanna use.  After that set the target to your player and the rotation damping to 0 so it doesn't turn at all when the player moves.

I think that will be what you're looking for and its a pretty simple FSM to make which makes everything better :)
Thank you. I don't know why I didn't tried it :D
Fixed it.

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: [Not Solved] Moving Camera with Player 😭😭😭
« Reply #3 on: November 28, 2018, 03:55:03 PM »
Update : I separated Player and camera. Then, applied Get Axis & Set velocity to camera. it worked. But, I have Colliders around Platform to make player to stay in play area. Once, reached that point, Player hit and stuck by Collider, but, camera keep moving. That makes, Player disappear from view.


Help me 😭😭😭😭
« Last Edit: November 29, 2018, 05:12:59 AM by heavygunner »

Athin

  • Full Member
  • ***
  • Posts: 163
Re: [Not Solved] Moving Camera with Player 😭😭😭
« Reply #4 on: November 28, 2018, 08:58:06 PM »
Was the Smooth Follow Action not working how you wanted?  Can't test but I believe using my answer from above would solve this.

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: [Not Solved] Moving Camera with Player 😭😭😭
« Reply #5 on: November 28, 2018, 11:16:05 PM »
Was the Smooth Follow Action not working how you wanted?  Can't test but I believe using my answer from above would solve this.

Oh ! I didn't noticed Smooth Follow Action. I just checked it, it working.

The Problem is : In my game, Player will be spawned once game launched. I set target "player" prefab from project folder. it not worked. It is focusing on random position. it is working only after I drag and dropped player(clone) from hierarchy.

So, in nutshell, That action not recognizing gameobject prefab from project, only scene object.


Thank you for the input :)
« Last Edit: November 29, 2018, 05:12:50 AM by heavygunner »

Athin

  • Full Member
  • ***
  • Posts: 163
Re: [Not Solved] Moving Camera with Player 😭😭😭
« Reply #6 on: November 28, 2018, 11:22:23 PM »
Hey there

Watching that video, the camera wouldn't have a target as its define as a prefab.  It will then default to look at 0,0,0 location I believe which is what you're seeing.  You can't use Prefabs the way you used them here.

Instead of throwing the prefab into the game object variable, spawn the player in and use the Get Owner action for that prefab.  Then use that variable as the target you want to follow.  Can be a global variable or can use the Get FSM Gameobject action depending on how you want to do it.  Dealers choice :)

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: [Not Solved] Moving Camera with Player 😭😭😭
« Reply #7 on: November 29, 2018, 05:12:33 AM »
Hey there

Watching that video, the camera wouldn't have a target as its define as a prefab.  It will then default to look at 0,0,0 location I believe which is what you're seeing.  You can't use Prefabs the way you used them here.

Instead of throwing the prefab into the game object variable, spawn the player in and use the Get Owner action for that prefab.  Then use that variable as the target you want to follow.  Can be a global variable or can use the Get FSM Gameobject action depending on how you want to do it.  Dealers choice :)
yay !
Thank you man.
I fixed and working. Thank you very much