How to shoot in direction of main actor?

Have any questions or problems in making your game, subscribing and/or using our software? Post here.
Forum rules
Make sure you are using the newest version. This can be downloaded at the top of the site via the "downloads" link.

Use a very good subject. "Problem" or "Help" are unacceptable titles.

Use the search feature before posting a question, as the answer is probably already here.

Subscript out of range error 9: This is a generic error, and we'll need way more information than that to figure out the problem. If you get this, strongly consider following the instructions of submitting your project through the Submit Bug feature within the editor.
User avatar
Danny
001 Forum Master
 
Joined: Tue Jul 12, 2011 7:14 am

How to shoot in direction of main actor?

Postby Danny » Sun Jan 24, 2016 9:55 am

So i have a enemy that shoots his weapon and i want him to shoot at the main players direction. The enemy as Ai turned off and i scripted it so it shoots itself.

I can't figure out how to make the enemy shoot in the direction of the main player. I tried this.



When the enemy shoots it only shoots left or right.

This is for the "Front" template. (Platformer)

Thanks.

User avatar
SBG
001 Subscriber
 
Joined: Thu Jun 17, 2010 8:37 pm
Location: merca

Re: How to shoot in direction of main actor?

Postby SBG » Sun Jan 24, 2016 12:17 pm

You need to use the change facing direction event on the actor to face the player, then have it use weapon.

User avatar
Danny
001 Forum Master
 
Joined: Tue Jul 12, 2011 7:14 am

Re: How to shoot in direction of main actor?

Postby Danny » Sun Jan 24, 2016 12:24 pm

SBG wrote:You need to use the change facing direction event on the actor to face the player, then have it use weapon.


Thats not going to possible. My enemy is a 2D Overlay Sprite with only 1 idle pose with 4 animation frames to make him spin in a circle. Hes always going to be spinning. How am i suppose to make him face the main player?

Edit: Doing that is not possible. I can only enter 1 value in the change facing direction event.

User avatar
SBG
001 Subscriber
 
Joined: Thu Jun 17, 2010 8:37 pm
Location: merca

Re: How to shoot in direction of main actor?

Postby SBG » Sun Jan 24, 2016 1:14 pm

Oh, you were wanting the pc to shoot at angles and stuff. Sorry man, not sure. I know it can be easily faked if you were using top down view to make a platformer, but I'm not sure how in an actual platformer view.

User avatar
Danny
001 Forum Master
 
Joined: Tue Jul 12, 2011 7:14 am

Re: How to shoot in direction of main actor?

Postby Danny » Tue Jan 26, 2016 11:12 am

I got this to work perfect in topdown but i can't figure it out in platformer view. No matter what i do he shoots only left and right :( I need him to shoot at the players direction at all times. Is there anyone here at all that knows what i need to do? Remember this is for a platformer front view. I have a feeling the Z position will play a part here but don't know how... :(


Bump! - Could really do with some help here please. Thanks.

Bump! - Please can someone tell me how to do this?

User avatar
RamchuK_Ntertainment
Ultimate 001 Member
 
Joined: Tue Sep 29, 2009 10:50 pm
Location: Seattle, Washington

Re: How to shoot in direction of main actor?

Postby RamchuK_Ntertainment » Wed Jan 27, 2016 4:33 pm

All you have to do is change the actor's Y Direction; copy the use value that you use in the "Use Weapon" event. You also don't need to use the "Use Weapon" event necessarily, unless you want to override the accuracy of the weapon being used.
Travesty: 3D Survival - WIP >>> Forum Topic
University of Washington (BABA)
-REGT- Ramchuk Entertainment Games Team
Strategy/Action/Adventure
Copyrighted©2008-2017

User avatar
Danny
001 Forum Master
 
Joined: Tue Jul 12, 2011 7:14 am

Re: How to shoot in direction of main actor?

Postby Danny » Wed Jan 27, 2016 7:43 pm

RamchuK_Ntertainment wrote:All you have to do is change the actor's Y Direction; copy the use value that you use in the "Use Weapon" event. You also don't need to use the "Use Weapon" event necessarily, unless you want to override the accuracy of the weapon being used.


I don't follow. Where do i change that?

User avatar
RamchuK_Ntertainment
Ultimate 001 Member
 
Joined: Tue Sep 29, 2009 10:50 pm
Location: Seattle, Washington

Re: How to shoot in direction of main actor?

Postby RamchuK_Ntertainment » Thu Jan 28, 2016 2:41 pm

In a 'While' Actor trigger, set an interval to a desired value and then use the "Change Aim/Look Angle Y". Then retrieve the following Direction: Geometry.DirectionY(Actor("this").X,Actor("this").Y,Actor("this").Z,Actor("main").X,Actor("main").Y,Actor("main").Z) This will change the Y angle of the actor to always aim at the player's position. NOTE: This will not rotate the actor along the Y-axis. If you'd like the actor to rotate along with it's Aim angle, use the "Change Rotation Y" event inside the timer as well.
Travesty: 3D Survival - WIP >>> Forum Topic
University of Washington (BABA)
-REGT- Ramchuk Entertainment Games Team
Strategy/Action/Adventure
Copyrighted©2008-2017

User avatar
Danny
001 Forum Master
 
Joined: Tue Jul 12, 2011 7:14 am

Re: How to shoot in direction of main actor?

Postby Danny » Thu Jan 28, 2016 5:56 pm

RamchuK_Ntertainment wrote:In a 'While' Actor trigger, set an interval to a desired value and then use the "Change Aim/Look Angle Y". Then retrieve the following Direction: Geometry.DirectionY(Actor("this").X,Actor("this").Y,Actor("this").Z,Actor("main").X,Actor("main").Y,Actor("main").Z) This will change the Y angle of the actor to always aim at the player's position. NOTE: This will not rotate the actor along the Y-axis. If you'd like the actor to rotate along with it's Aim angle, use the "Change Rotation Y" event inside the timer as well.


The setup you mentioned is not working. I have a While Timer trigger set to 0.001 with the following event set up inside



I also have another while timer setup set to 0.5 with this event.



The enemy is firing oddly and not towards the player. To make things easier please watch the video below. What am i doing wrong? Thank you. :)


https://www.youtube.com/watch?v=BrUM_PZTka8


Return to Technical Support Questions

Who is online

Users browsing this forum: No registered users

cron