playMaker

Author Topic: Lock mechanic similar to Kingdom hearts or Dark souls  (Read 524 times)

paradiseprime

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
Lock mechanic similar to Kingdom hearts or Dark souls
« on: December 17, 2018, 03:55:04 AM »
I am using cinemachine with great success and am able to target a character and orbit around them but the issue now is how do I get a list of targets infront of me then allow myself to toggle between them with the right stick?

How do I get all the targets infront of me then get the distance of each and list them in order from closest to farthest in an array?

Athin

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: Lock mechanic similar to Kingdom hearts or Dark souls
« Reply #1 on: December 17, 2018, 04:10:44 AM »
What I'd do is throw all your enemies into an Array that you want to try to lock onto.  Then whenever the player tries to lock on, use the Array List Get Closest Game Object with the player as the target to check against.  From there you should be able to then check distance to see if they are close enough to be allowed to lock on as well as switch to the next one in the array.

paradiseprime

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
Re: Lock mechanic similar to Kingdom hearts or Dark souls
« Reply #2 on: December 17, 2018, 07:33:32 AM »
What I'd do is throw all your enemies into an Array that you want to try to lock onto.  Then whenever the player tries to lock on, use the Array List Get Closest Game Object with the player as the target to check against.  From there you should be able to then check distance to see if they are close enough to be allowed to lock on as well as switch to the next one in the array.

This is a solid idea but the issue is that if the enemies are behind me then it would spin the camera around and target the enemy which is something I dont want. My solution was to target everything in camera view up a distance and list them in a array then sort them by distance and use the right stick to toggle between them.

The issue with that idea is I dont know how to get all targets in camera view.

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 125
    • View Profile
Re: Lock mechanic similar to Kingdom hearts or Dark souls
« Reply #3 on: December 17, 2018, 06:48:00 PM »
You only put the enemies you want into the array list. One example would be to use a trigger that has an FSM that adds and removes enemies as they leave and enter the trigger. This is at least what I did and it worked well.

Jim132

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Lock mechanic similar to Kingdom hearts or Dark souls
« Reply #4 on: December 17, 2018, 10:39:03 PM »
You only put the enemies you want into the array list. One example would be to use a trigger that has an FSM that adds and removes enemies as they leave and enter the trigger. This is at least what I did and it worked well.

That's a good idea! Maybe you can set a trigger in front of your camera! ;D

paradiseprime

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
Re: Lock mechanic similar to Kingdom hearts or Dark souls
« Reply #5 on: December 18, 2018, 11:18:55 AM »
You only put the enemies you want into the array list. One example would be to use a trigger that has an FSM that adds and removes enemies as they leave and enter the trigger. This is at least what I did and it worked well.

That's a good idea! Maybe you can set a trigger in front of your camera! ;D


It is a great idea but what kind of trigger would I put infront of the camera? What shape?

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 125
    • View Profile
Re: Lock mechanic similar to Kingdom hearts or Dark souls
« Reply #6 on: December 18, 2018, 02:16:40 PM »
My game was 2D, but for 3D I would guess you would need a pyramid/triangle-shaped trigger to match the perspective?