0
Answered

Auto lock on ennemies ?

Dornano 5 months ago in Game Creator updated by Marti (Lead Developer) 5 months ago 14

When the player is near an ennemy, I would like him to rotate towards him automatically. There is the "Rotate towards" action for that, but I must specify an instance of the ennemy, while I would like to rotate on any ennemy nearby (maybe using tags for ex?)

Unity version:
Game Creator version:
GOOD, I'M SATISFIED
Satisfaction mark by Dornano 5 months ago

maybe if you have the behaviour module, a condition is can see. instead of invoker can see, just use player cn see invoker

then rotate towards invoker

I will test that in the morning

I think the "Combat for Game Creator" asset by Fire Chicken Games might do that for you. Check it out on the Unity Asset Store. There is a RVR YouTube channel tutorial that covers this as well.

Yeah, that will do it too. Going to buy that but I was actually waiting also for actions pack 1 to be approved and buy some stuff together.

Good idea, thanks, I've just bought Behavior module so I just tried this idea.

And indeed, the Player is doing his rotation towards the Invoker, but once. He's not "locked", at least for some seconds, you see what I mean?

can you explain more what you then want to do? Do you want the player to stay locked on the enemy even when the enemy is moving or just shoot at the enemy as soon as you have turned towards him?

Not sure what you are wishing to do.

Sure. When I hold Ctrl key, the Player enter in "Combat mode" and is aiming nearby enemies automatically. So when you press E key, he launches an attack in direction of the locked ennemy. You still can walk, but very slowly, and always while aiming the enemy.

I don't know if you can see well, but like this (from 48:50) :



And when you release Ctrl key, you leave the Combat mode and go back to the normal directional input, you no longer lock anyone and can walk and run again.


By the way, I've tried the "Rotate towards" Action with Invoker as a Target, but in fact, it breaks everything, because now, while I walk in my level, my Player is rotating topretty much everything :o

(And thanks for trying to help me ^^)

I'll give it a try later on. but I think you just need a trigger holding ctrl key then look at nearest gameobject with tag enemy and then a condition if Ctrl key down then when e key is pressed launch attack and releasing the Ctrl key will stop the action / behaviour restarting.


I will also be buying the combat module today, so I will take a look at that too.

I'm not sure we can look at tag, but if you try, tell me your results ^^

I found an easy solution. Just going to finish it up and then I will post instructions here.

+1
  1. Put a player in the scene
  2. Add a perception component
  3. Add a shooter component
  1. Add a Character and set him a little away from the player
  2. Add a shooter component
  3. Create 3 or 4 markers around the player for the character to run around
  4. Create a Trigger OnStart and an 3 or 4 actions move character, select marker and add your markers.
  5. TEST, the character should run around the markers.
  6. Now make a new Trigger on key down, Left Control
  7. Then add a condition can see player, select gameObject and drag character to that.
  8. Add an action player draw weapon, player aim at game object character, player look at game object character
  9. Click on condition the ELSE and add an action, Player stop aiming
  10. To shoot create a new Trigger on mouse down left, Action shoot weapon
  11. Make a new Trigger on key up Left control, add an action player stop aiming

I thank you a lot for all your research, eagleeyez ! I'm pretty sure your solution would work, but I feel bad to say I don't have the Shooter module ^^; Since my gameplay is mainly based on exploration, and has a very basic combat system (just hit enemy with a stick, nothing else), I didn't feel the need to buy the Shooter module :o I just have Behavior.

+1

you can still do that with just GC and a State animation hit with stick and use colliders to make hit boxes.

Then have it subtract a variable each time until dead and then set a ragdoll.

But with shooter and / or Melee you'll have more fun and also be equiped for future projects.

Thanks for your help eagleeyez ^^

Indeed that's what I've done. I managed to make Player attack, put a hitbox on his weapon, and when the enemy is touched, make him loose some life points. And it's working well, without any auto-lock tricks. So it's nice !

Just, if Marti pass by there, I would be interested anyway to know what he thinks about auto-lock anyway ^^

+1
Answered

Hi! The Beasthunt demo will show how to make use of an Auto lock feature using Actions and Conditions. It's quite easy, although I think there was a little catch that needed to first be addressed in the core of Game Creator.

I'm marking this ticket as complete since it's going to be out soon. I wouldn't use the Can See condition, since an enemy might be hidding behind a column and would still need to be able to target it.

Instead, use the Action Gather Components by Distance, using the Character component, and select the second index (if any).