CN112245909B - Method and device for locking object in game - Google Patents

Method and device for locking object in game Download PDF

Info

Publication number
CN112245909B
CN112245909B CN202011255997.7A CN202011255997A CN112245909B CN 112245909 B CN112245909 B CN 112245909B CN 202011255997 A CN202011255997 A CN 202011255997A CN 112245909 B CN112245909 B CN 112245909B
Authority
CN
China
Prior art keywords
spherical
spherical coordinates
coordinates
target
mapping
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011255997.7A
Other languages
Chinese (zh)
Other versions
CN112245909A (en
Inventor
尹骏
宁博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202011255997.7A priority Critical patent/CN112245909B/en
Publication of CN112245909A publication Critical patent/CN112245909A/en
Application granted granted Critical
Publication of CN112245909B publication Critical patent/CN112245909B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/40Processing input control signals of video game devices, e.g. signals generated by the player or derived from the environment
    • A63F13/42Processing input control signals of video game devices, e.g. signals generated by the player or derived from the environment by mapping the input signals into game commands, e.g. mapping the displacement of a stylus on a touch screen to the steering angle of a virtual vehicle
    • A63F13/426Processing input control signals of video game devices, e.g. signals generated by the player or derived from the environment by mapping the input signals into game commands, e.g. mapping the displacement of a stylus on a touch screen to the steering angle of a virtual vehicle involving on-screen location information, e.g. screen coordinates of an area at which the player is aiming with a light gun
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • A63F13/525Changing parameters of virtual cameras
    • A63F13/5258Changing parameters of virtual cameras by dynamically adapting the position of the virtual camera to keep a game object or game character in its viewing frustum, e.g. for tracking a character or a ball
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/55Controlling game characters or game objects based on the game progress
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/30Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by output arrangements for receiving control signals generated by the game device
    • A63F2300/308Details of the user interface

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Human Computer Interaction (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the invention provides a method and a device for locking an object in a game, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring one or more interactable objects in the virtual scene according to the virtual character; acquiring position information of the one or more interactable objects in the virtual scene; determining spherical coordinates corresponding to the one or more interactable objects respectively according to the position information, wherein the spherical coordinates are coordinates in a spherical coordinate system determined according to the virtual character; determining target spherical coordinates according to the spherical coordinates of the virtual character and the interactable object; the interactable object corresponding to the target spherical coordinates is used as the locking object of the virtual character and is locked, so that the optimal target object can be locked for the virtual character without using a character camera, the consumption of system resources is reduced, and game errors possibly caused by adopting two target object locking methods are avoided.

Description

Method and device for locking object in game
Technical Field
The present invention relates to the field of computers, and in particular, to a method and apparatus for locking an object in a game, an electronic device, and a storage medium.
Background
The target object locking function is a commonly used function in games, and can be used for providing a visualized target object for a player, wherein the player can perform a fight operation on the target object, such as attack on the target object, and can also perform an interactive operation on the target object, such as when the target object is a wooden case, the player can lift the wooden case and throw the wooden case, and in addition, the target object can also be applied to other functions, such as a destination serving as an automatic road finding function, and the like. As shown in fig. 1, which is a scenario in a game scene and in which a target object is unlocked, 101 is a virtual character controlled by a player, 102 is a non-player character, when the player locks the non-player character 102, as shown in fig. 2, a mark 201 for indicating that the target object has been locked appears on the top of the head of the non-player character 102, at this time, the player can select a direction through an external device, such as a keyboard, a joystick, etc., the locked target object can be changed from 102 to other interactable target objects in the selected direction, as shown in fig. 3, when the player presses a left direction key of the keyboard, the locked target object is changed to another non-player character 301 on the left side of the player 102, and a mark 302 appears on the top of the head.
The existing target object locking function needs to project targets in a game scene onto screen coordinates, then select the targets to be locked on a two-dimensional plane, and the targets are also selected on the two-dimensional plane. However, this screen-based approach is not applicable to AI (Artificial Intelligence ) controlled roles. Because the character controlled by the AI has no concept of a character camera, that is, the targets in the scene cannot be projected onto the screen presented by the character camera following the character, if the target locking of the AI character is to be realized, a target object locking method different from the character operated by the player needs to be adopted, so that more system resources are required to be consumed, the consistency of the two target object locking methods is difficult to be ensured, and the two target object locking methods are easy to collide to cause game errors.
Disclosure of Invention
In view of the foregoing, the present invention has been made to provide a method and apparatus for in-game object locking, an electronic device, a storage medium, which overcome or at least partially solve the foregoing problems, including:
in order to solve the above-mentioned problems, an embodiment of the present invention discloses a method for locking an object in a game, providing a graphical user interface through a terminal device, where a content displayed on the graphical user interface includes a part or all of virtual scenes and virtual characters located in the virtual scenes, and the method includes:
Acquiring one or more interactable objects in the virtual scene according to the virtual character;
acquiring position information of the one or more interactable objects in the virtual scene;
determining spherical coordinates corresponding to the one or more interactable objects respectively according to the position information, wherein the spherical coordinates are coordinates in a spherical coordinate system determined according to the virtual character;
determining target spherical coordinates according to the spherical coordinates of the virtual character and the interactable object;
and taking the interactable object corresponding to the target spherical coordinate as a locking object of the virtual character and locking.
Preferably, the virtual character is a non-player controlled character.
Preferably, the step of acquiring one or more interactable objects in the virtual scene according to the virtual character comprises:
judging whether the type of the object is consistent with a preset type; the types include combat interaction classes and non-combat interaction classes;
if yes, determining the object as a preliminary screening object;
judging whether the distance between the preliminary screening object and the virtual character is smaller than a preset threshold value or not;
if yes, detecting whether a shielding object exists between the preliminary screening object and the virtual character;
And if no shielding object exists, determining the preliminary screening object as an interactable object.
Preferably, the step of determining spherical coordinates corresponding to the one or more interactable objects according to the position information includes:
constructing a spherical coordinate system by taking the virtual character as a center;
acquiring three-dimensional Cartesian coordinates of the interactable object based on the position information;
and converting the three-dimensional Cartesian coordinates into spherical coordinates in the spherical coordinate system.
Preferably, the step of determining target spherical coordinates from spherical coordinates of the virtual character and the interactable object comprises:
a first target spherical coordinate is determined based on a first angle difference and a first distance between spherical coordinates of the virtual character and the interactable object.
Preferably, the step of determining a first target spherical coordinate based on a first angle difference and a first distance between spherical coordinates of the virtual character and the interactable object comprises:
taking the direction facing by the virtual character as a projection direction, and acquiring the projection spherical coordinates of the virtual character on a unit spherical surface of the spherical coordinate system in the projection direction;
Mapping the spherical coordinates of the interactable object into first mapped spherical coordinates taking the projected spherical coordinates as an origin;
determining a first angle difference and a first distance between the interactable object and the virtual character using the first mapped spherical coordinates;
traversing the first mapping spherical coordinates, and determining the first target spherical coordinates according to the first angle difference and the first distance.
Preferably, the step of traversing the first mapped spherical coordinates and determining the first target spherical coordinates from the first angle difference and the first distance includes:
traversing the first mapping spherical coordinates, and judging whether the difference value between the first angle differences exceeds a preset threshold value;
if not, selecting the first mapping spherical coordinate with smaller first distance as a first target spherical coordinate;
if yes, selecting the first mapping spherical coordinate with the smaller first angle difference as the first target spherical coordinate.
Preferably, the virtual character is a player-controlled character, and the method further comprises:
responding to the direction instruction input by the player, and acquiring locking spherical coordinates corresponding to the object locked by the virtual character;
Mapping the spherical coordinates of the interactable object into second mapped spherical coordinates taking the locked spherical coordinates as an origin;
determining a second angle difference and a second distance between the interactable object and the object locked by the virtual character by adopting the second mapping spherical coordinates;
traversing the second mapping spherical coordinates, and determining the second target spherical coordinates according to the second angle difference and the second distance;
and switching the object locked by the virtual character into a target interactable object corresponding to the spherical coordinates of the second target.
Preferably, the step of determining a second angle difference and a second distance between the interactable object and the virtual character using the second mapped spherical coordinates comprises:
determining corresponding two-dimensional coordinates by adopting the direction instruction;
selecting a target mapped spherical coordinate from the second mapped spherical coordinate based on the two-dimensional coordinate;
and calculating a second angle difference and a second distance between the target mapping spherical coordinates and the origin by adopting the target mapping spherical coordinates and a preset weight.
Preferably, the step of selecting the target mapping spherical coordinates from the second mapping spherical coordinates based on the two-dimensional coordinates includes:
Judging whether the abscissa of the two-dimensional coordinate is greater than zero;
if yes, determining a second mapping spherical coordinate with a component larger than and/or equal to zero in the vertical direction from the second mapping spherical coordinates as a screening mapping spherical coordinate;
if not, determining a second mapping spherical coordinate with a component smaller than and/or equal to zero in the vertical direction from the second mapping spherical coordinates as a screening mapping spherical coordinate;
judging whether the ordinate of the two-dimensional coordinate is larger than zero;
if the ordinate of the two-dimensional coordinate is greater than zero, selecting a screening mapping spherical coordinate with a component greater than and/or equal to zero in the horizontal direction from the screening mapping spherical coordinate as a target mapping spherical coordinate;
and if the ordinate of the two-dimensional coordinate is smaller than zero, selecting the screening mapping spherical coordinate with the component smaller than and/or equal to zero in the horizontal direction from the screening mapping spherical coordinate as the target mapping spherical coordinate.
The embodiment of the invention also discloses a device for locking the object in the game, which provides a graphical user interface through terminal equipment, wherein the content displayed by the graphical user interface comprises part or all of virtual scenes and virtual roles positioned in the virtual scenes, and the device comprises:
An interactable object acquisition module for acquiring one or more interactable objects in the virtual scene according to the virtual character;
a position information acquisition module, configured to acquire position information of the one or more interactable objects in the virtual scene;
the spherical coordinate determining module is used for determining spherical coordinates corresponding to the one or more interactable objects respectively according to the position information, wherein the spherical coordinates are coordinates in a spherical coordinate system determined according to the virtual character;
the target spherical coordinate determining module is used for determining target spherical coordinates according to the spherical coordinates of the virtual character and the interactable object;
and the locking object module is used for taking the interactable object corresponding to the target spherical coordinate as the locking object of the virtual character and locking the interactable object.
The embodiment of the invention also provides electronic equipment, which comprises a processor, a memory and a computer program stored on the memory and capable of running on the processor, wherein the computer program realizes the steps of the method for locking the object in the game when being executed by the processor.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and the computer program is executed by a processor to realize the steps of the method for locking the object in the game.
The invention has the following advantages:
in the embodiment of the invention, the position information of one or more interactable objects in the virtual scene is acquired by acquiring one or more interactable objects in the virtual scene according to the virtual character, the spherical coordinates corresponding to the one or more interactable objects respectively are determined according to the position information, the target spherical coordinates are determined according to the spherical coordinates of the virtual character and the interactable objects, and the interactable object corresponding to the target spherical coordinates is used as a locking object of the virtual character and is locked. The whole process can lock the optimal target object for the virtual character without using a character camera, is suitable for the virtual character controlled by a player and an AI, reduces the consumption of system resources and avoids the possible game errors caused by adopting the two target object locking methods.
Drawings
In order to more clearly illustrate the technical solutions of the present invention, the drawings that are needed in the description of the present invention will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort to a person skilled in the art.
FIG. 1 is a schematic diagram of a game scenario provided by an embodiment of the present invention;
FIG. 2 is a schematic diagram of a locking target object according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a target object for handover locking according to an embodiment of the present invention;
FIG. 4 is a flowchart of steps in a method for in-game object locking provided by an embodiment of the present invention;
FIG. 5 is a flowchart of steps in another method for in-game object locking provided by an embodiment of the present invention;
FIG. 6 is a schematic diagram of the construction of a spherical coordinate system according to the embodiment of the present invention;
FIG. 7 is a block diagram of an apparatus for locking an object in a game according to an embodiment of the present invention.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description. It will be apparent that the described embodiments are some, but not all, embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The method of in-game object locking in one embodiment of the invention may be run on a terminal device or a server. The terminal device may be a local terminal device. When the method for locking the object in the game runs on the server, the method for locking the object in the game can be realized and executed based on a cloud interaction system, wherein the cloud interaction system comprises the server and the client device.
In an alternative embodiment, various cloud applications may be run under the cloud interaction system, for example: and (5) cloud game. Taking cloud game as an example, cloud game refers to a game mode based on cloud computing. In the running mode of the cloud game, the running main body of the game program and the game picture presentation main body are separated, the storage and running of the method for locking the objects in the game are completed on the cloud game server, and the client device is used for receiving and sending data and presenting the game pictures, for example, the client device can be a display device with a data transmission function close to a user side, such as a mobile terminal, a television, a computer, a palm computer and the like; however, the terminal device of the method for locking the object in the game is a cloud game server in the cloud. When playing the game, the player operates the client device to send an operation instruction to the cloud game server, the cloud game server runs the game according to the operation instruction, codes and compresses data such as game pictures and the like, returns the data to the client device through a network, and finally decodes the data through the client device and outputs the game pictures.
In an alternative embodiment, the terminal device may be a local terminal device. Taking a game as an example, the local terminal device stores a game program and is used to present a game screen. The local terminal device is used for interacting with the player through the graphical user interface, namely, conventionally downloading and installing the game program through the electronic device and running. The manner in which the local terminal device provides the graphical user interface to the player may include a variety of ways, for example, it may be rendered for display on a display screen of the terminal, or provided to the player by holographic projection. For example, the local terminal device may include a display screen for presenting a graphical user interface including game visuals, and a processor for running the game, generating the graphical user interface, and controlling the display of the graphical user interface on the display screen.
Referring to fig. 4, a flowchart illustrating steps of a method for locking an object in a game according to an embodiment of the present invention is provided, by a terminal device, a graphical user interface, where a content displayed by the graphical user interface includes a part or all of a virtual scene, and a virtual character located in the virtual scene, and the method specifically may include the following steps:
step 401, obtaining one or more interactable objects in the virtual scene according to the virtual character;
the virtual scenes can be game scenes in the game, and the objects in the game scenes can be divided into two types according to the function playing methods to be executed at present: interactive objects, which may include non-player enemies when performing an attack operation, and non-interactive objects, which may include non-player friendly characters, for example, for role-playing class games; while in the case of a give item operation, the interactable object may comprise a non-player friendly character and the non-interactable object may comprise a non-player enemy. According to the function playing method to be executed at present, one or more objects which can execute the function playing method to be executed at present in the virtual scene can be determined as interactable objects, and interactable objects meeting the requirements of users can be screened out from a plurality of objects in the virtual scene in a screening mode.
Step 402, obtaining position information of the one or more interactable objects in the virtual scene;
after determining the interactable objects, the positions of one or more interactable objects in the virtual scene may be obtained, respectively.
Step 403, determining spherical coordinates corresponding to the one or more interactable objects respectively according to the position information, wherein the spherical coordinates are coordinates in a spherical coordinate system determined according to the virtual character;
the spherical coordinate system is one of three-dimensional coordinate systems for determining the positions of points, lines, planes and bodies in three-dimensional space, and is composed of azimuth angle, elevation angle and distance by taking the origin of coordinates as a reference point. After the position information of the interactable objects in the virtual scene is obtained, the virtual character is taken as the origin of coordinates, and the spherical coordinates of each interactable object are obtained through coordinate conversion according to the position information.
Step 404, determining target spherical coordinates according to the spherical coordinates of the virtual character and the interactable object;
the virtual character includes a target character controlled by AI, and after the spherical coordinates of each interactable object are obtained, when the target character has no locked object, the most suitable spherical coordinates can be determined by the distance and angle difference between the spherical coordinates of the target character, i.e., the origin of coordinates, and the spherical coordinates of the interactable object. For example, the spherical coordinates having the smallest angle difference or the spherical coordinates of the target having the smallest distance when the angle difference is the same may be used.
And step 405, taking the interactable object corresponding to the target spherical coordinate as a locking object of the virtual character and locking.
And taking the interactable object corresponding to the target spherical coordinate as a locked object, and locking the interactable object.
In the embodiment of the invention, the position information of one or more interactable objects in the virtual scene is acquired by acquiring one or more interactable objects in the virtual scene according to the virtual role, the spherical coordinates corresponding to the one or more interactable objects respectively are determined according to the position information, the target spherical coordinates are determined according to the spherical coordinates of the virtual role and the interactable objects, the interactable object corresponding to the target spherical coordinates is used as a locking object of the virtual role and is locked, the optimal target object can be locked for the virtual role without using a role camera in the whole process, and the method is suitable for the virtual role controlled by a player and an AI (automatic identification) and not only reduces the consumption of system resources, but also avoids game errors possibly caused by adopting two target object locking methods.
Referring to fig. 5, a flowchart illustrating steps of another method for locking an object in a game according to an embodiment of the present invention is provided, where a graphical user interface is provided by a terminal device, and contents displayed by the graphical user interface include a part or all of virtual scenes and virtual characters located in the virtual scenes, and the method specifically may include the following steps:
Step 501, obtaining one or more interactable objects in the virtual scene according to the virtual character;
in a preferred embodiment of the present invention, the step 501 comprises the following sub-steps:
judging whether the type of the object in the virtual scene is consistent with a preset type; the types include combat types and interaction types;
if yes, determining the object as a preliminary screening object;
judging whether the distance between the preliminary screening object and the virtual character is smaller than a preset threshold value or not;
if yes, detecting whether a shielding object exists between the preliminary screening object and the virtual character;
and if no shielding object exists, determining the preliminary screening object as an interactable object.
The preset type is set according to the playing method or action to be executed by the player or AI, when the executed playing method is a combat playing method, such as releasing attack skills and defending attack from enemies, the type can be determined to be a combat interaction type, when the executed playing method is a non-combat playing method, such as giving articles and a carrying case, the type at the moment is determined to be a non-combat interaction type, whether the objects in the virtual scene are consistent with the preset type is determined, and when the objects are consistent with the preset type, the objects can be determined to be primary screening objects. For example, when the predetermined type is a combat interaction class, then one or more enemy persons in the virtual scene are determined to be preliminary screening objects.
In a game, generally, the interaction between a player or an AI-controlled character and an interactable object has a distance limitation, for example, when the player-controlled character performs an interactive operation of attacking an enemy, the player can only attack the enemy with the distance between the player and the character within an attack range, if the attack range of the character is 1 meter, the enemy with the distance between the player and the character controlled by the player within 1 meter can be attacked and the enemy beyond 1 meter is not affected by the attack. Therefore, in order to prevent locking of the object exceeding the interactable distance, whether the distance between the primary screening object and the virtual character is smaller than a preset threshold value is judged, and if yes, the primary screening object is considered to be influenced by the interaction operation of the virtual character. Further, in order to make the interaction in the game more in line with the logic of real life, the input degree of the player is improved, after it is determined that the primary screening object can be affected by the interaction operation of the virtual character, whether a shielding object exists between the primary screening object and the virtual character is also required to be detected, if the shielding object exists, the interaction operation is considered to be unable to be completed, for example, when the attack operation is executed, a wall is spaced between the character controlled by the player and the enemy in the attack range, according to the logic of real life, the character cannot know that the enemy exists behind the wall or can not attack the enemy behind the wall through the wall, so that the primary screening object can be determined as the interactable object only when the shielding object does not exist between the virtual character and the primary screening object. It should be noted that the detection mode may be selected according to the needs of those skilled in the art, for example, a radiation detection mode may be adopted, which is not limited by the present invention.
Step 502, constructing a spherical coordinate system by taking the virtual character as a center;
a spherical coordinate system is constructed with a virtual character controlled by a player or AI as the origin of coordinates.
Step 503, obtaining three-dimensional cartesian coordinates of the interactable object based on the position information;
the three-dimensional cartesian coordinate system passes through a fixed point and is used as three mutually perpendicular axes, which are all about the fixed point as the origin of coordinates and generally have the same length units, and these three axes are respectively called an x-axis (horizontal axis), a y-axis (vertical axis), and a z-axis (vertical axis), and are collectively referred to as coordinate axes. The x-axis and y-axis are typically arranged in a horizontal plane, while the z-axis is a plumb line. And obtaining the three-dimensional Cartesian coordinates of the interactable object in the virtual scene through the obtained position information.
Step 504, converting the three-dimensional cartesian coordinates into spherical coordinates in the spherical coordinate system;
specifically, as shown in fig. 6, a point P is the origin of coordinates where the virtual character is located, a point a is the three-dimensional cartesian coordinates of an interactable object, and a point B is spherical coordinates in a spherical coordinate system converted from the three-dimensional cartesian coordinates of the interactable object. Spherical coordinates can be expressed asWherein r represents the distance between the point A and the origin of coordinates, θ represents the angle between the directional line BP and the positive direction of the z axis, and +. >Representing the angle between the projection of the directed line segment BP on the xy plane and the positive x-axis. Assume that the three-dimensional Cartesian coordinates of point A are (x a ,y a ,z a ) The three-dimensional cartesian coordinates of the point P are (x p ,y p ,z p ) The three-dimensional Cartesian coordinate value of the point A minus the three-dimensional Cartesian coordinate value of the point P is (x) a-p ,y a-p ,z a-p ) Taking point a as an example, point a is converted to point B according to the following formula:
the three-dimensional cartesian coordinates of each interactable object are converted into spherical coordinates.
Step 505, determining target spherical coordinates according to the spherical coordinates of the virtual character and the interactable object;
in a preferred embodiment of the present invention, the step 505 comprises the following sub-steps:
a first target spherical coordinate is determined based on a first angle difference and a first distance between spherical coordinates of the virtual character and the interactable object.
After the target spherical coordinates are determined, by comparing the angle difference and the distance between the spherical coordinates of the virtual character and the one or more interactable objects as the origin of the spherical coordinates system, the target spherical coordinates which are most suitable as the interactable objects of the locking objects can be determined from the spherical coordinates of the plurality of interactable objects according to the preset comparison rule.
In a preferred embodiment of the present invention, the step of determining the first target spherical coordinates based on the first angle difference and the first distance between the spherical coordinates of the virtual character and the interactable object further comprises:
taking the direction facing by the virtual character as a projection direction, and acquiring the projection spherical coordinates of the virtual character on a unit spherical surface of the spherical coordinate system in the projection direction;
mapping the spherical coordinates of the interactable object into first mapped spherical coordinates taking the projected spherical coordinates as an origin;
determining a first angle difference and a first distance between the interactable object and the virtual character using the first mapped spherical coordinates;
traversing the first mapping spherical coordinates, and determining the first target spherical coordinates according to the first angle difference and the first distance.
In the embodiment of the invention, the virtual character can be the virtual character controlled by the AI, and since the locked object does not exist at the beginning, the virtual character controlled by the AI needs to be projected as a point on the spherical surface in front, so as to fictitiously construct a currently locked interactable object. An optimal lock object is then selected based on the interactable object. Therefore, according to the direction faced by the virtual character, the projected spherical coordinates of the virtual character on the unit spherical surface of the spherical coordinate system can be obtained, then the projected spherical coordinates are used as the origin, the mapped spherical coordinates of the interactable object are obtained, the angle difference and the distance between the interactable object and the target character can be determined by adopting the mapped spherical coordinates, all the mapped spherical coordinates are traversed, and the mapped spherical coordinates of the most suitable locking object, namely the first target spherical coordinates, can be selected from the projected spherical coordinates according to the angle difference and the distance.
Specifically, if the spherical coordinates of the virtual character projected onto the unit sphere directly in front of the virtual character are set as point C, the spherical coordinates of the interactable object are mapped to mapped spherical coordinates with the point C as the originThe formula of (2) is:
when (when)
When (when)
Wherein,representing the component of the spherical coordinates of the interactable object in the horizontal direction. />Representing the component of point C in the horizontal direction. />Representing the mapped new value. According to the formula, +.>The value of (2) is [ -pi, pi]And thus ensures that the value of point C is 0,and the optimal point is convenient to select according to the size of the coordinate value.
Similarly, θ in the mapped spherical coordinates can be calculated according to the following formula 2 Is the value of (1):
θ 2 =θ 1c
when (theta) 2 >π),θ 2 =θ 2 -2π;
When (theta) 2 <π),θ 2 =θ 2 +2π;
Wherein θ 1 Representing the component of the spherical coordinates of the interactable object in the vertical direction. θ c Representing the component of point C in the vertical direction, θ 2 Representing the mapped new value.
After the mapped spherical coordinates of the interactable object are obtained, a first angle difference and a first distance between the interactable object and the virtual character may be calculated by the following formula:
wherein Angle is the Angle difference, abs represents the absolute value, and the distance r is a known parameter.
In a preferred embodiment of the present invention, the step of traversing the first mapped spherical coordinates and determining the first target spherical coordinates according to the first angle difference and the first distance further comprises the sub-steps of:
Traversing the first mapping spherical coordinates, and judging whether the difference value between the first angle differences exceeds a preset threshold value;
if not, selecting the first mapping spherical coordinate with smaller first distance as a first target spherical coordinate;
if yes, selecting the first mapping spherical coordinate with the smaller first angle difference as the first target spherical coordinate.
And judging whether the difference value between the angle differences corresponding to the mapped spherical coordinates exceeds a preset threshold value by traversing the mapped spherical coordinates, if so, reserving the mapped spherical coordinates with smaller angle differences, continuing to compare with the rest mapped spherical coordinates until the difference value is within the preset threshold value, and comparing the distance between the two mapped spherical coordinates and the virtual character, and selecting the mapped spherical coordinates with smaller distance, wherein the mapped spherical coordinates are the spherical coordinates of the locked object, namely the target spherical coordinates.
Specifically, the mapping spherical coordinates may be traversed and the target spherical coordinates determined as follows:
(1) If the first mapped spherical coordinate currently traversed, there are:
BestIdx=Idx;
BestAngle=Angle;
BestDist=r;
and (2) when the condition that the index of the current traversal is equal to the index of the current traversal, each mapping spherical coordinate has a corresponding index, and the first mapping spherical coordinate of the current traversal is satisfied, repeating the step (1). If not, entering the next step, namely, the step (2):
(2) When BestAngle-Angle > MinLockSwitchAngle, then there are:
BestIdx=Idx;
BestAngle=Angle;
BestDist=r;
repeating the step (2), otherwise, entering the step (3)
Where MinLockSwitchAngle represents an angle threshold of spatial angular proximity of two interactable objects, which may take 1 as an example. In the step, the difference operation is performed by using the traversed angle difference between the first mapped spherical coordinate and the second mapped spherical coordinate, when the result is larger than the preset angle threshold, the angle difference between the first mapped spherical coordinate and the origin of coordinates is considered to be larger than the angle difference between the second mapped spherical coordinate and the origin of coordinates, so that the second mapped spherical coordinate is used as the current optimal mapped spherical coordinate, the index of the second mapped spherical coordinate is used as the current optimal target index, the angle difference of the second mapped spherical coordinate is used as the current optimal angle difference, the distance of the second mapped spherical coordinate is used as the current optimal distance, the process is repeated, namely, the traversing of the mapped spherical coordinates is continued, and when the result is smaller than the preset angle threshold, the step (3) is entered.
(3) When abs (BestAngle-Angle) < MinLockSwitchAngle and BestDist > r, then there are:
BestIdx=Idx;
BestAngle=Angle;
BestDist=r;
returning to the step (2) until all the mapped spherical coordinates are traversed.
When the difference between the current optimal angle difference and the angle difference of the currently traversed mapping spherical coordinates is smaller than a preset angle threshold and the current optimal distance is larger than the distance of the currently traversed mapping spherical coordinates, namely, the spatial distance between the current optimal interactable object and the interactable object corresponding to the currently traversed mapping spherical coordinates is similar, but the distance between the current optimal interactable object and the coordinate origin, namely, the virtual role is far, so that the currently traversed mapping spherical coordinates are used as optimal mapping spherical coordinates, the index thereof is used as a current optimal target index, the angle difference thereof is used as the current optimal angle difference, the distance thereof is used as the current optimal distance, then the step (2) is returned until all the mapping spherical coordinates are traversed, the interactable objects are screened according to the spatial angles, the preferred angle difference is the smallest, if the angle difference is close, the distance is selected, and the finally obtained optimal mapping spherical coordinates are the first target spherical coordinates corresponding to the selected locking objects.
And step 506, taking the interactable object corresponding to the target spherical coordinate as a locking object of the virtual character and locking.
After the target spherical coordinates are determined, the interactable object corresponding to the target spherical coordinates can be confirmed to be a locking object with the optimal virtual character, and the operation of locking the object is executed.
In a preferred embodiment of the present invention, the virtual character is a player-controlled character, and the method further comprises:
responding to the direction instruction input by the player, and acquiring locking spherical coordinates corresponding to the object locked by the virtual character;
mapping the spherical coordinates of the interactable object into second mapped spherical coordinates taking the locked spherical coordinates as an origin;
determining a second angle difference and a second distance between the interactable object and the object locked by the virtual character by adopting the second mapping spherical coordinates;
traversing the second mapping spherical coordinates, and determining the second target spherical coordinates according to the second angle difference and the second distance;
and switching the object locked by the virtual character into a target interactable object corresponding to the spherical coordinates of the second target.
Specifically, when the player wants to switch the locked object when the virtual character controlled by the player has a locked object in the virtual scene, the player can input a direction instruction, for example, through a keyboard key or a handle rocker, for example, after the player attacks the locked enemy in a battle of the game, according to the judgment of the battle situation, the player wants to attack another enemy on the left side of the locked enemy, and at this time, the player can press a left direction key on the keyboard to switch the locked enemy to the other enemy. After receiving the direction instruction input by the player, acquiring the spherical coordinates of the locked object, and taking the spherical coordinates as the origin, acquiring the mapped spherical coordinates of the interactable object after the spherical coordinates of the interactable object are mapped, wherein the specific calculation mode can refer to the mapping spherical coordinates of the interactable object mapped to the mapped spherical coordinates taking the point C as the origin The angle difference and the distance between the interactable object and the object locked by the target role can be determined by adopting the mapping spherical coordinates, and the specific calculation mode can refer to the mapping spherical coordinates> And traversing all the mapping spherical coordinates in a calculation mode of the angle difference and the distance between the mapping spherical coordinates and the target role, selecting the most suitable mapping spherical coordinates of the locked object according to the angle difference and the distance, specifically, judging whether the difference value between the angle differences corresponding to the mapping spherical coordinates exceeds a preset threshold value by traversing the mapping spherical coordinates, if so, reserving the mapping spherical coordinates with smaller angle difference, continuing to compare with the rest mapping spherical coordinates until the difference value is within the preset threshold value, comparing the distance between the mapping spherical coordinates and the virtual role, and selecting the mapping spherical coordinates with smaller distance, wherein the mapping spherical coordinates are the spherical coordinates of the locked object, namely the spherical coordinates of the second target. After the second target spherical coordinates are determined, the object currently locked by the virtual character is switched to the target interactable object corresponding to the second target spherical coordinates, so that the object locked by the virtual character is changed.
In a preferred embodiment of the present invention, the step of determining a second angular difference and a second distance between the interactable object and the virtual character using the second mapped spherical coordinates further comprises the sub-steps of:
Determining corresponding two-dimensional coordinates by adopting the direction instruction;
selecting a target mapped spherical coordinate from the second mapped spherical coordinate based on the two-dimensional coordinate;
and calculating a second angle difference and a second distance between the target mapping spherical coordinates and the origin by adopting the target mapping spherical coordinates and a preset weight.
Specifically, after receiving the direction command input by the player, the game engine determines a two-dimensional coordinate according to the direction command conversion, for example, the player presses the w key representing the front on the keyboard, then the two-dimensional coordinate (1, 0) can be determined, and the interactable object can be primarily screened according to the two-dimensional coordinate, namely, the direction of the interactable object selected by the player is determinedInteractable objects with the same sphere coordinate value range, such as right direction key of direction key pressed by player, need to exclude interactable object positioned at left of screen, namelyThe mapping spherical coordinates smaller than 0, so as to obtain the target mapping spherical coordinates, since there are mapping spherical coordinates which are not consistent with the direction selected by the player in the target mapping spherical coordinates, in order to further screen the interactable objects which are more consistent with the direction selected by the player, when calculating the second angle difference between the target mapping spherical coordinates and the origin, a weight value can be added to the target mapping spherical coordinates which are consistent with the direction selected by the player, that is, the second angle difference and the second distance between the target mapping spherical coordinates and the origin are calculated by adopting the target mapping spherical coordinates and the preset weight value, for example, the calculation can be performed by the following formula:
Wherein x and y are preset weights.
In a preferred embodiment of the present invention, the step of selecting the target mapped spherical coordinates from the second mapped spherical coordinates based on the two-dimensional coordinates further includes the sub-steps of:
judging whether the abscissa of the two-dimensional coordinate is greater than zero;
if yes, determining a second mapping spherical coordinate with a component larger than and/or equal to zero in the vertical direction from the second mapping spherical coordinates as a screening mapping spherical coordinate;
if not, determining a second mapping spherical coordinate with a component smaller than and/or equal to zero in the vertical direction from the second mapping spherical coordinates as a screening mapping spherical coordinate;
judging whether the ordinate of the two-dimensional coordinate is larger than zero;
if the ordinate of the two-dimensional coordinate is greater than zero, selecting a screening mapping spherical coordinate with a component greater than and/or equal to zero in the horizontal direction from the screening mapping spherical coordinate as a target mapping spherical coordinate;
and if the ordinate of the two-dimensional coordinate is smaller than zero, selecting the screening mapping spherical coordinate with the component smaller than and/or equal to zero in the horizontal direction from the screening mapping spherical coordinate as the target mapping spherical coordinate.
Upon receiving a direction instruction input by the player, a two-dimensional coordinate (x 1 ,y 1 ) The second mapped spherical coordinates may be screened, specifically, x 1 Representing the up-down direction of the screen, and y 1 Representing the left-right direction of the screen, if x 1 Above 0, then the object with θ less than 0 needs to be excluded, i.e., a second mapped spherical coordinate with a component in the vertical direction greater than and/or equal to zero is selected; if x 1 If the value is smaller than 0, the object with theta larger than 0 is needed to be eliminated, namely, a second mapping spherical coordinate with the component smaller than and/or equal to zero in the vertical direction is selected, screening is carried out according to the abscissa, screening mapping spherical coordinates are obtained, and then ordinate screening is carried out on the screening mapping spherical coordinates. Similarly, if y 1 Greater than 0, then need to be eliminatedA target smaller than 0, namely selecting screening mapping spherical coordinates with components in the horizontal direction larger than and/or equal to zero; if y 1 If the ratio is less than 0, the +.>And selecting a screening mapping spherical coordinate with a component smaller than and/or equal to zero in the horizontal direction as a target with a value larger than 0, and finally obtaining the screening mapping spherical coordinate after the vertical coordinate selection.
By applying the embodiment of the invention, one or more interactable objects in a virtual scene are obtained according to the virtual role, a spherical coordinate system is constructed by taking the virtual role as the center, three-dimensional Cartesian coordinates of the interactable objects are obtained based on position information, the three-dimensional Cartesian coordinates are converted into spherical coordinates in the spherical coordinate system, the target spherical coordinates are determined according to the spherical coordinates of the virtual role and the interactable objects, the interactable objects corresponding to the target spherical coordinates are used as locking objects of the virtual role and locked, after locking, a direction instruction input by a player is responded, the locking spherical coordinates corresponding to the objects locked by the virtual role are obtained, the spherical coordinates of the interactable objects are mapped into second mapped spherical coordinates by taking the locking spherical coordinates as an origin, a second angle difference and a second distance between the interactable objects and the objects locked by the virtual role are determined by adopting the second mapped spherical coordinates, the second angle difference and the second distance are determined, the objects locked by the virtual role are switched into the target interactable objects corresponding to the second target spherical coordinates, and the target spherical coordinates corresponding to the second target spherical coordinates, and the interactable objects corresponding to the second target spherical coordinates are not locked by the virtual role, and the locking objects are switched, and the game objects can be accurately selected from the two game objects and the game objects are not needed by the player.
Referring to fig. 7, which is a block diagram illustrating a device for locking an object in a game according to an embodiment of the present invention, a graphical user interface is provided through a terminal device, and contents displayed on the graphical user interface include a part or all of virtual scenes and virtual characters located in the virtual scenes, the device may include the following modules:
an interactable object obtaining module 601, configured to obtain one or more interactable objects in the virtual scene according to the virtual character;
a location information obtaining module 602, configured to obtain location information of the one or more interactable objects in the virtual scene;
a spherical coordinate determining module 603, configured to determine spherical coordinates corresponding to the one or more interactable objects according to the location information, where the spherical coordinates are coordinates in a spherical coordinate system determined according to the virtual character;
a target spherical coordinate determining module 604, configured to determine a target spherical coordinate according to spherical coordinates of the virtual character and the interactable object;
and the locking object module 605 is configured to take the interactable object corresponding to the target spherical coordinate as a locking object of the virtual character and lock the interactable object.
In one embodiment of the present invention, the interactable object obtaining module 601 includes:
the type submodule is used for judging whether the type of the object in the virtual scene is consistent with a preset type; the types include combat interaction classes and non-combat interaction classes;
the preliminary screening sub-module is used for determining the object as a preliminary screening object if the object is consistent with a preset type;
the distance judging sub-module is used for judging whether the distance between the preliminary screening object and the virtual character is smaller than a preset threshold value or not;
the shielding sub-module is used for detecting whether a shielding object exists between the preliminary screening object and the virtual character or not if the distance between the preliminary screening object and the virtual character is smaller than a preset threshold value;
and the interactable object determining sub-module is used for determining the preliminary screening object as the interactable object if no shielding object exists.
In an embodiment of the present invention, the spherical coordinate determining module 603 includes:
a spherical coordinate system construction submodule for constructing a spherical coordinate system by taking the virtual character as a center;
the three-dimensional Cartesian coordinate acquisition sub-module is used for acquiring the three-dimensional Cartesian coordinate of the interactable object based on the position information;
And the conversion sub-module is used for converting the three-dimensional Cartesian coordinates into spherical coordinates in the spherical coordinate system.
In one embodiment of the present invention, the target spherical coordinate determining module 604 includes:
and the first target spherical coordinate determining submodule is used for determining the first target spherical coordinate based on a first angle difference and a first distance between the spherical coordinates of the virtual character and the interactable object.
In an embodiment of the present invention, the first target spherical coordinate determination submodule includes:
the projection spherical coordinate unit is used for taking the direction facing by the virtual character as a projection direction, and acquiring the projection spherical coordinate of the virtual character on the unit spherical surface of the spherical coordinate system in the projection direction;
the first mapping spherical coordinate unit is used for mapping the spherical coordinates of the interactable object into first mapping spherical coordinates taking the projection spherical coordinates as an origin;
a first angle difference and first distance determining unit configured to determine a first angle difference and a first distance between the interactable object and the virtual character using the first mapped spherical coordinates;
and the traversing unit is used for traversing the first mapping spherical coordinates and determining the first target spherical coordinates according to the first angle difference and the first distance.
In an embodiment of the present invention, the virtual character is a player-controlled character, and the apparatus further includes:
the locking spherical coordinate module is used for responding to the direction instruction input by the player and acquiring locking spherical coordinates corresponding to the object locked by the virtual character;
the second mapping spherical coordinate module is used for mapping the spherical coordinates of the interactable object into second mapping spherical coordinates taking the locking spherical coordinates as an origin;
a second angle difference and second distance determining module, configured to determine a second angle difference and a second distance between the interactable object and the object locked by the virtual character using the second mapped spherical coordinates;
the second target spherical coordinate determining module is used for traversing the second mapping spherical coordinate and determining the second target spherical coordinate according to the second angle difference and the second distance;
and the switching module is used for switching the object locked by the virtual role into a target interactable object corresponding to the second target spherical coordinate.
In one embodiment of the present invention, the traversal unit includes:
a preset threshold subunit, configured to traverse the first mapped spherical coordinates, and determine whether a difference value between the first angle differences exceeds a preset threshold;
A first selecting unit, configured to select, as a first target spherical coordinate, a first mapped spherical coordinate with a smaller first distance if a difference value between the first angle differences does not exceed a preset threshold value;
and the second selecting unit is used for selecting the first mapping spherical coordinate with the smaller first angle difference as the first target spherical coordinate if the difference value between the first angle differences exceeds a preset threshold value.
In an embodiment of the present invention, the second angle difference and second distance determining module includes:
the two-dimensional coordinate determining submodule is used for determining corresponding two-dimensional coordinates by adopting the direction instruction;
a target mapping spherical coordinate sub-module for selecting a target mapping spherical coordinate from the second mapping spherical coordinate based on the two-dimensional coordinate;
and the second angle difference and second distance calculation sub-module is used for calculating a second angle difference and a second distance between the target mapping spherical coordinates and the origin by adopting the target mapping spherical coordinates and a preset weight.
In an embodiment of the present invention, the object mapping spherical coordinates submodule includes:
the first judging unit is used for judging whether the abscissa of the two-dimensional coordinates is larger than zero or not;
The first screening mapping spherical coordinate unit is used for determining a second mapping spherical coordinate with a component larger than and/or equal to zero in the vertical direction from the second mapping spherical coordinate as a screening mapping spherical coordinate if the abscissa of the two-dimensional coordinate is larger than zero;
the second screening mapping spherical coordinate unit is used for determining a second mapping spherical coordinate with a component smaller than and/or equal to zero in the vertical direction from the second mapping spherical coordinate as a screening mapping spherical coordinate if the abscissa of the two-dimensional coordinate is smaller than zero;
the second judging unit is used for judging whether the ordinate of the two-dimensional coordinate is larger than zero;
the first target mapping spherical coordinate selection unit is used for selecting the screening mapping spherical coordinate with the component larger than and/or equal to zero in the horizontal direction from the screening mapping spherical coordinate as the target mapping spherical coordinate if the ordinate of the two-dimensional coordinate is larger than zero;
and the second target mapping spherical coordinate selection unit is used for selecting the screening mapping spherical coordinate with the component smaller than and/or equal to zero in the horizontal direction from the screening mapping spherical coordinate as the target mapping spherical coordinate if the ordinate of the two-dimensional coordinate is smaller than zero.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
An embodiment of the present invention also provides an electronic device that may include a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program implementing the steps of the method for object locking in a game as described above when executed by the processor.
An embodiment of the invention also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of object locking in a game as above.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the invention may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or terminal device comprising the element.
The above description of the method and apparatus for locking an object in a game, the electronic device, and the storage medium provided by the present invention applies specific examples to illustrate the principles and embodiments of the present invention, and the description of the above examples is only used to help understand the method and core idea of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (13)

1. A method of in-game object locking, wherein a graphical user interface is provided by a terminal device, the graphical user interface displaying content including part or all of a virtual scene, and a virtual character located in the virtual scene, the method comprising:
acquiring one or more interactable objects in the virtual scene according to the virtual character;
acquiring position information of the one or more interactable objects in the virtual scene;
determining spherical coordinates corresponding to the one or more interactable objects respectively according to the position information, wherein the spherical coordinates are coordinates in a spherical coordinate system determined according to the virtual character;
Determining target spherical coordinates according to the spherical coordinates of the virtual character and the interactable object;
and taking the interactable object corresponding to the target spherical coordinate as a locking object of the virtual character and locking.
2. The method of claim 1, wherein the virtual character is a non-player controlled character.
3. The method of claim 1, wherein the step of obtaining one or more interactable objects in the virtual scene from the virtual character comprises:
judging whether the type of the object in the virtual scene is consistent with a preset type; the types include combat interaction classes and non-combat interaction classes;
if yes, determining the object as a preliminary screening object;
judging whether the distance between the preliminary screening object and the virtual character is smaller than a preset threshold value or not;
if yes, detecting whether a shielding object exists between the preliminary screening object and the virtual character;
and if no shielding object exists, determining the preliminary screening object as an interactable object.
4. The method of claim 1, wherein the step of determining spherical coordinates corresponding to the one or more interactable objects, respectively, from the location information comprises:
Constructing a spherical coordinate system by taking the virtual character as a center;
acquiring three-dimensional Cartesian coordinates of the interactable object based on the position information;
and converting the three-dimensional Cartesian coordinates into spherical coordinates in the spherical coordinate system.
5. The method of claim 4, wherein the step of determining target spherical coordinates from spherical coordinates of the virtual character and the interactable object comprises:
a first target spherical coordinate is determined based on a first angle difference and a first distance between spherical coordinates of the virtual character and the interactable object.
6. The method of claim 5, wherein the step of determining a first target spherical coordinate based on a first angle difference and a first distance between spherical coordinates of the virtual character and the interactable object comprises:
taking the direction facing by the virtual character as a projection direction, and acquiring the projection spherical coordinates of the virtual character on a unit spherical surface of the spherical coordinate system in the projection direction;
mapping the spherical coordinates of the interactable object into first mapped spherical coordinates taking the projected spherical coordinates as an origin;
Determining a first angle difference and a first distance between the interactable object and the virtual character using the first mapped spherical coordinates;
traversing the first mapping spherical coordinates, and determining the first target spherical coordinates according to the first angle difference and the first distance.
7. The method of claim 6, wherein the step of traversing the first mapped spherical coordinates to determine the first target spherical coordinates from the first angular difference and the first distance comprises:
traversing the first mapping spherical coordinates, and selecting the first mapping spherical coordinates with the smallest first angle difference as first target spherical coordinates;
and traversing the first mapping spherical coordinates, and taking the first mapping spherical coordinates currently traversed as first target spherical coordinates if the absolute value of the difference value between the first angle difference of the first mapping spherical coordinates currently traversed and the first angle difference of the first target spherical coordinates is smaller than a preset threshold value and the first distance of the first mapping spherical coordinates currently traversed is smaller than the first distance of the first target spherical coordinates.
8. The method of claim 4, wherein the virtual character is a player-controlled character, the method further comprising:
Responding to the direction instruction input by the player, and acquiring locking spherical coordinates corresponding to the object locked by the virtual character;
mapping the spherical coordinates of the interactable object into second mapped spherical coordinates taking the locked spherical coordinates as an origin;
determining a second angle difference and a second distance between the interactable object and the object locked by the virtual character by adopting the second mapping spherical coordinates;
traversing the second mapping spherical coordinates, and determining second target spherical coordinates according to the second angle difference and the second distance;
and switching the object locked by the virtual character into a target interactable object corresponding to the spherical coordinates of the second target.
9. The method of claim 8, wherein the step of determining a second angular difference and a second distance between the interactable object and the virtual character using the second mapped spherical coordinates comprises:
determining corresponding two-dimensional coordinates by adopting the direction instruction;
selecting a target mapped spherical coordinate from the second mapped spherical coordinate based on the two-dimensional coordinate;
and calculating a second angle difference and a second distance between the target mapping spherical coordinates and the origin by adopting the target mapping spherical coordinates and a preset weight.
10. The method of claim 9, wherein the step of selecting target mapped spherical coordinates from the second mapped spherical coordinates based on the two-dimensional coordinates comprises:
judging whether the abscissa of the two-dimensional coordinate is greater than zero;
if yes, determining a second mapping spherical coordinate with a component larger than and/or equal to zero in the vertical direction from the second mapping spherical coordinates as a screening mapping spherical coordinate;
if not, determining a second mapping spherical coordinate with a component smaller than and/or equal to zero in the vertical direction from the second mapping spherical coordinates as a screening mapping spherical coordinate;
judging whether the ordinate of the two-dimensional coordinate is larger than zero;
if the ordinate of the two-dimensional coordinate is greater than zero, selecting a screening mapping spherical coordinate with a component greater than and/or equal to zero in the horizontal direction from the screening mapping spherical coordinate as a target mapping spherical coordinate;
and if the ordinate of the two-dimensional coordinate is smaller than zero, selecting the screening mapping spherical coordinate with the component smaller than and/or equal to zero in the horizontal direction from the screening mapping spherical coordinate as the target mapping spherical coordinate.
11. An apparatus for in-game object locking, wherein a graphical user interface is provided by a terminal device, the graphical user interface displaying content including a part or all of a virtual scene, and a virtual character located in the virtual scene, the apparatus comprising:
An interactable object acquisition module for acquiring one or more interactable objects in the virtual scene according to the virtual character;
a position information acquisition module, configured to acquire position information of the one or more interactable objects in the virtual scene;
the spherical coordinate determining module is used for determining spherical coordinates corresponding to the one or more interactable objects respectively according to the position information, wherein the spherical coordinates are coordinates in a spherical coordinate system determined according to the virtual character;
the target spherical coordinate determining module is used for determining target spherical coordinates according to the spherical coordinates of the virtual character and the interactable object;
and the locking object module is used for taking the interactable object corresponding to the target spherical coordinate as the locking object of the virtual character and locking the interactable object.
12. An electronic device comprising a processor, a memory and a computer program stored on the memory and executable on the processor, the computer program when executed by the processor performing the steps of the method of in-game object locking as claimed in any one of claims 1 to 10.
13. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the method of in-game object locking according to any of claims 1 to 10.
CN202011255997.7A 2020-11-11 2020-11-11 Method and device for locking object in game Active CN112245909B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011255997.7A CN112245909B (en) 2020-11-11 2020-11-11 Method and device for locking object in game

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011255997.7A CN112245909B (en) 2020-11-11 2020-11-11 Method and device for locking object in game

Publications (2)

Publication Number Publication Date
CN112245909A CN112245909A (en) 2021-01-22
CN112245909B true CN112245909B (en) 2024-03-15

Family

ID=74265414

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011255997.7A Active CN112245909B (en) 2020-11-11 2020-11-11 Method and device for locking object in game

Country Status (1)

Country Link
CN (1) CN112245909B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113521738A (en) * 2021-08-11 2021-10-22 网易(杭州)网络有限公司 Special effect generation method and device, computer readable storage medium and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007105499A (en) * 2007-01-09 2007-04-26 Namco Bandai Games Inc Game system, program and information storage medium
CN101808702A (en) * 2008-03-24 2010-08-18 科乐美数码娱乐株式会社 Instruction content decision device, instruction content decision method, information recording medium, and program
CN105302434A (en) * 2015-06-16 2016-02-03 深圳市腾讯计算机***有限公司 Method and device for locking targets in game scene
CN111886880A (en) * 2018-04-09 2020-11-03 杜比国际公司 Method, apparatus and system for three degrees of freedom (3DOF +) extension of MPEG-H3D audio

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007105499A (en) * 2007-01-09 2007-04-26 Namco Bandai Games Inc Game system, program and information storage medium
CN101808702A (en) * 2008-03-24 2010-08-18 科乐美数码娱乐株式会社 Instruction content decision device, instruction content decision method, information recording medium, and program
CN105302434A (en) * 2015-06-16 2016-02-03 深圳市腾讯计算机***有限公司 Method and device for locking targets in game scene
CN111886880A (en) * 2018-04-09 2020-11-03 杜比国际公司 Method, apparatus and system for three degrees of freedom (3DOF +) extension of MPEG-H3D audio

Also Published As

Publication number Publication date
CN112245909A (en) 2021-01-22

Similar Documents

Publication Publication Date Title
US11004272B2 (en) Image processing method, electronic apparatus, and storage medium
WO2016202005A1 (en) Method and terminal for locking target in game scene
US9649561B2 (en) Rendering control apparatus, control method thereof, recording medium, rendering server, and rendering system
JP4425274B2 (en) Method and apparatus for adjusting the view of a scene being displayed according to the motion of the head being tracked
WO2019218815A1 (en) Method and device for displaying marker elements in virtual scene, computer device, and computer-readable storage medium
US9764226B2 (en) Providing enhanced game mechanics
RU2617914C2 (en) Systems and methods for cloud computing and imposing content on streaming video frames of remotely processed applications
US20210370170A1 (en) Information Processing Method and Apparatus, Electronic Device, and Storage Medium
US20080143722A1 (en) Simultaneous view and point navigation
CN109925720A (en) Information processing method and device
US20120293412A1 (en) Method and system for tracking of a subject
US9004997B1 (en) Providing enhanced game mechanics
CN110833694B (en) Display control method and device in game
JP2010517129A (en) Reality enhancement method and apparatus for automatically tracking textured planar geometric objects in real time without marking in a video stream
US20240070974A1 (en) Method and apparatus for displaying virtual environment picture, device, and storage medium
JP2022544888A (en) Interface display method, device, terminal, storage medium and computer program
US11423605B2 (en) Systems and methods for remastering a game space while maintaining the underlying game simulation
CN112245909B (en) Method and device for locking object in game
US20230082928A1 (en) Virtual aiming control
Piumsomboon et al. Physically-based interaction for tabletop augmented reality using a depth-sensing camera for environment mapping
US20230356075A1 (en) Method, computer device, and storage medium for virtual object switching
CN114404986A (en) Method and device for controlling player character, electronic device and storage medium
CN111389004A (en) Control method of virtual role, storage medium and processor
US20210117070A1 (en) Computer-readable recording medium, computer apparatus, and method of controlling
CN111939563A (en) Target locking method, device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant