top of page
Search
Writer's pictureAbish Neel

Week 3: Aim-based Passing and Player Lock-on

Updated: Jul 7, 2023


Picking up where I left off the previous week, I iterated over the passing system to take into consideration the controller left stick orientation. This means that the ball gets passed in the direction of orientation of the left stick. However, this made it extremely hard to pass it to other players so I had to add in a lock-on mechanic which helps lock onto a target that close enough to the selected passing lane. This is done by doing a dot product between the stick orientation with the direction vectors of the currently controlled players to all other players in the scene and finding if the the angle is less than 30 degrees (~0.5 radians). If it's less than the threshold (currently hard-coded), the pass gets locked onto that player, if not the pass goes in the direction of the left stick orientation.


You may be thinking that looping through all players in the scene and calculating all the direction vectors between them and the player is quite expensive, and I would agree with you on that. Although the final goal for this project is only a 3v3 game mode and the total number of players in the scene will be 6 (also I will be looping through only teammate players which cuts the number in half), I am going to try to come up with a more optimal way of doing this in the coming weeks.


Updated passing logic that takes in controller stick orientation to pass in that direction or lock-on to a target close-enough to that passing lane.


The other significant change made to the project this week was making an actual football field for the players to play on so it looks better. While I was on the subject of making the game look better I also implemented a simple camera system which lerps to the ball's X and delta Y coordinates so there's no case of the ball getting lost off screen anymore, which was incredibly frustrating.


A video demonstrating the aim-based passing and lock on mechanic along with the camera system.


You may be thinking - this demonstration of simply running around and passing the ball looks boring, and I would say you're right. So the plan for the coming weeks will be to start working on an AI coordinator for teammate AI that makes teammates move into better spaces to receive passes and avoid opponent team players.

8 views0 comments

Recent Posts

See All

Comments


bottom of page