CN115888101A - Virtual role state switching method and device, storage medium and electronic equipment - Google Patents

Virtual role state switching method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN115888101A
CN115888101A CN202211540330.0A CN202211540330A CN115888101A CN 115888101 A CN115888101 A CN 115888101A CN 202211540330 A CN202211540330 A CN 202211540330A CN 115888101 A CN115888101 A CN 115888101A
Authority
CN
China
Prior art keywords
animation
switching
transition
virtual character
bone position
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.)
Pending
Application number
CN202211540330.0A
Other languages
Chinese (zh)
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 CN202211540330.0A priority Critical patent/CN115888101A/en
Publication of CN115888101A publication Critical patent/CN115888101A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the application discloses a method and a device for switching states of virtual roles, a storage medium and electronic equipment. The method comprises the following steps: responding to a state switching instruction aiming at the virtual character, and acquiring the current bone position of the virtual character from the currently played original state animation; determining a playing start frame from a switching animation according to the current bone position, wherein the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation; and starting to play the switching animation from the play start frame. The embodiment of the application can improve the fluency of the virtual character action during switching and improve the sense of reality of the animation expression effect.

Description

Virtual role state switching method and device, storage medium and electronic equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for switching states of virtual characters, a storage medium, and an electronic device.
Background
When the virtual character in the game is switched from the original state (such as traveling) to the target state (such as turning), the original state animation is directly switched to the target state animation for playing. However, the time for the player to trigger the virtual character to perform the state switching has uncertainty, which easily causes the animation frame when the animation in the original state is switched to be not matched with the animation first frame of the animation in the target state, i.e. the postures of the virtual character in the two animation frames are not consistent or discontinuous, so that the actions of the virtual character are jammed and jumped during the switching, and the actions are not smooth, and the animation expression effect is not real.
Disclosure of Invention
The embodiment of the application provides a method and a device for switching states of virtual characters, a storage medium and electronic equipment, which can improve the fluency of actions of the virtual characters during switching and improve the sense of reality of animation expression effects.
The embodiment of the application provides a virtual role state switching method, a graphical user interface is provided through electronic equipment, the graphical user interface comprises a virtual role, and the method comprises the following steps:
responding to a state switching instruction aiming at the virtual character, and acquiring the current bone position of the virtual character from the currently played original state animation;
determining a playing start frame from a switching animation according to the current bone position, wherein the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation;
and starting to play the switching animation from the play start frame.
An embodiment of the present application further provides a device for switching states of virtual roles, where a graphical user interface is provided through an electronic device, the graphical user interface includes a virtual role, and the device includes:
the acquisition module is used for responding to a state switching instruction aiming at the virtual character and acquiring the current bone position of the virtual character from the currently played original state animation;
the determining module is used for determining a playing start frame from a switching animation according to the current bone position, the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation;
and the playing module is used for playing the switching animation from the playing start frame.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored, where the computer program is suitable for being loaded by a processor to perform the steps in the method for switching the state of the virtual role according to any embodiment.
An embodiment of the present application further provides an electronic device, where the electronic device includes a memory and a processor, where the memory stores a computer program, and the processor executes, by calling the computer program stored in the memory, the steps in the method for switching states of a virtual role according to any of the above embodiments.
The method, the device, the storage medium and the electronic device for switching the state of the virtual character, provided by the embodiment of the application, respond to a state switching instruction for the virtual character, and acquire the current bone position of the virtual character from the currently played original state animation; determining a playing start frame from a switching animation according to the current bone position, wherein the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation; and starting to play the switching animation from the playing start frame. According to the embodiment of the application, the transition animation is added in the switching animation, so that when the virtual character is subjected to state switching, the animation frame corresponding to the current skeleton position of the virtual character is matched from the transition animation and used as the playing initial frame of the switching animation, the fluency of the action of the virtual character during switching is improved, the reality of the animation expression effect is improved, the matching is performed according to the skeleton position of the virtual character, the posture of the virtual character does not need to be identified, the animation resource amount and the data calculation amount are reduced, and the cost and the performance consumption are further reduced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a system diagram of a state switching device for virtual roles according to an embodiment of the present disclosure.
Fig. 2 is a flowchart illustrating a method for switching states of a virtual role according to an embodiment of the present disclosure.
Fig. 3 is a schematic diagram of a progress animation in a method for switching states of a virtual character according to an embodiment of the present application.
Fig. 4 is a schematic diagram of a progress animation curve in the method for switching states of a virtual character according to the embodiment of the present application.
Fig. 5 is a schematic diagram of a first candidate switching animation in a method for switching states of a virtual character according to an embodiment of the present application.
Fig. 6 is a schematic diagram of a second candidate switching animation in the method for switching states of a virtual character according to the embodiment of the present application.
Fig. 7 is a schematic diagram of a first candidate switching animation curve in a method for switching states of a virtual character according to an embodiment of the present application.
Fig. 8 is a schematic diagram of a second candidate switching animation curve in the method for switching the state of the virtual character according to the embodiment of the present application.
Fig. 9 is a schematic diagram of a left-foot animation curve switching in a state switching method for a virtual character according to an embodiment of the present application.
Fig. 10 is a schematic diagram of a right-foot switching animation curve in the virtual character state switching method according to the embodiment of the present application.
Fig. 11 is a schematic structural diagram of a state switching apparatus for virtual roles according to an embodiment of the present application.
Fig. 12 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a method and a device for switching states of virtual roles, a storage medium and electronic equipment. Specifically, the method for switching the state of the virtual role according to the embodiment of the present application may be executed by an electronic device, where the electronic device may be a terminal or a server. The terminal may be a terminal device such as a smart phone, a tablet Computer, a notebook Computer, a touch screen, a game console, a Personal Computer (PC), a Personal Digital Assistant (PDA), and the like, and the terminal may further include a client, which may be a game application client, a browser client carrying a game program, or an instant messaging client, and the like. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, a cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and a big data and artificial intelligence platform.
For example, when the state switching method of the virtual character is operated on the terminal, the terminal device stores a game application and is used for presenting a virtual scene in a game screen. The terminal device is used for interacting with a user through a graphical user interface, for example, downloading and installing a game application program through the terminal device and running the game application program. The manner in which the terminal device provides the graphical user interface to the user may include a variety of ways, for example, the graphical user interface may be rendered for display on a display screen of the terminal device or presented by holographic projection. For example, the terminal device may include a touch display screen for presenting a graphical user interface including a game screen and receiving operation instructions generated by a user acting on the graphical user interface, and a processor for executing the game, generating the graphical user interface, responding to the operation instructions, and controlling display of the graphical user interface on the touch display screen.
For example, when the state switching method of the virtual character is executed on a server, the virtual character may be a cloud game. Cloud gaming refers to a gaming regime based on cloud computing. In the running mode of the cloud game, the running main body of the game application program and the game picture presenting main body are separated, and the storage and the running of the skill control method are finished on the cloud game server. The game screen presentation is performed at a cloud game client, which is mainly used for receiving and sending game data and presenting the game screen, for example, the cloud game client may be a display device with a data transmission function near a user side, such as a mobile terminal, a television, a computer, a palm computer, a personal digital assistant, and the like, but a terminal device for performing game data processing is a cloud game server at the cloud end. When a game is played, a user operates the cloud game client to send an operation instruction to the cloud game server, the cloud game server runs the game according to the operation instruction, data such as game pictures and the like are encoded and compressed, the data are returned to the cloud game client through a network, and finally the data are decoded through the cloud game client and the game pictures are output.
Referring to fig. 1, fig. 1 is a system schematic diagram of a state switching device of a virtual role according to an embodiment of the present disclosure. The system may include a plurality of terminals 1000, at least one server 2000, at least one database 3000, and a network 4000. The terminal 1000 held by the user can be connected to servers of different games through the network 4000. Terminal 1000 can be any device having computing hardware capable of supporting and executing a software product corresponding to a game. In addition, terminal 1000 can have one or more multi-touch sensitive screens for sensing and obtaining user input through touch or slide operations performed at multiple points on one or more touch sensitive display screens. In addition, when the system includes a plurality of terminals 1000, a plurality of servers 2000, and a plurality of networks 4000, different terminals 1000 may be connected to each other through different networks 4000 and through different servers 2000. The network 4000 may be a wireless network or a wired network, such as a Wireless Local Area Network (WLAN), a Local Area Network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, and so on. In addition, different terminals 1000 may be connected to other terminals or a server using their own bluetooth network or hotspot network. For example, a plurality of users may be online through different terminals 1000 to be connected and synchronized with each other through a suitable network to support multiplayer games. In addition, the system may include a plurality of databases 3000, the plurality of databases 3000 being coupled to different servers 2000, and information related to the game environment may be continuously stored in the databases 3000 when different users play the multiplayer game online.
The embodiment of the application provides a method for switching the state of a virtual role, which can be executed by a terminal or a server. The embodiment of the present application describes a state switching method of a virtual role as an example executed by a terminal. The terminal comprises a touch display screen and a processor, wherein the touch display screen is used for presenting a graphical user interface and receiving an operation instruction generated by a user acting on the graphical user interface. When a user operates the graphical user interface through the touch display screen, the graphical user interface can control the local content of the terminal through responding to the received operation instruction, and can also control the content of the opposite-end server through responding to the received operation instruction. For example, the operating instructions generated by the user acting on the graphical user interface include instructions for launching the game application, and the processor is configured to launch the game application after receiving the instructions provided by the user to launch the game application. Further, the processor is configured to render and draw a graphical user interface associated with the game on the touch display screen. A touch display screen is a multi-touch sensitive screen capable of sensing a touch or slide operation performed at a plurality of points on the screen at the same time. The user uses a finger to perform touch operation on the graphical user interface, and when the graphical user interface detects the touch operation, different virtual objects in the graphical user interface of the game are controlled to perform actions corresponding to the touch operation. Wherein the game may comprise a virtual scene of the game drawn on a graphical user interface. Further, one or more virtual objects, such as virtual characters, controlled by the user (or player) may be included in the virtual scene of the game. Additionally, one or more obstacles, such as railings, ravines, walls, and the like, may also be included in the virtual scene of the game to limit movement of the virtual objects, e.g., to limit movement of the one or more objects to a particular area within the virtual scene. Optionally, the virtual scene of the game also includes one or more elements, such as skills, points, character health, energy, etc., to provide assistance to the player, provide virtual services, increase points related to player performance, etc. In addition, the graphical user interface may also present one or more indicators to provide instructional information to the player. For example, a game may include a player-controlled virtual object and one or more other virtual objects (such as enemy characters). In one embodiment, one or more other virtual objects are controlled by other players of the game. For example, one or more other virtual objects may be computer controlled, such as a robot using Artificial Intelligence (AI) algorithms, implementing a human-machine fight mode. For example, the virtual objects possess various skills or capabilities that the game player uses to achieve the goal. For example, the virtual object possesses one or more weapons, props, tools, etc. that can be used to eliminate other objects from the game. Such skills or capabilities may be activated by a player of the game using one of a plurality of preset touch operations with a touch display screen of the terminal. The processor may be configured to present a corresponding game screen in response to an operation instruction generated by a touch operation of a user.
The following detailed description is given with reference to specific examples.
Please refer to fig. 2, which is a flowchart illustrating a method for switching states of a virtual role according to an embodiment of the present disclosure. The method for switching the state of the virtual role provided by the embodiment of the application is applied to the electronic equipment, and the specific flow of the method can be as follows:
step 101, responding to a state switching instruction aiming at the virtual character, and acquiring the current bone position of the virtual character from the currently played original state animation.
In this embodiment, the electronic device provides a graphical user interface, the graphical user interface includes a game scene, and the virtual character is located in the game scene. The game scene is a virtual environment provided by the game running on the electronic device, and the virtual environment can be a simulation environment of a real world, a semi-simulation semi-fictional three-dimensional environment or a pure fictional three-dimensional environment. The virtual character refers to a character which is active in a game scene, such as a virtual character and the like.
The virtual character may have multiple states in the game scene, such as traveling (including walking, running), turning, stopping, jumping, squatting, lying down, standing, and the like. The states can be switched, for example, the virtual character can be switched from squatting to standing, or from standing to squatting. Each state corresponds to a state animation, the electronic equipment plays the state animation on the graphical user interface to realize the state display of the virtual character, and the state switching of the virtual character is realized through the switching of the state animation.
The state-switch instruction may be triggered in a number of ways. For example, the virtual character may be controlled by a game player who operates the virtual character on the electronic device to change the state of the virtual character, thereby triggering generation of a state switching instruction. For another example, a change in the environment in which the virtual character is located in the game scene causes the virtual character state to need to change, thereby triggering generation of the state switching instruction.
The electronic device needs to switch the virtual character from one state to another state according to the state switching instruction. The state of the virtual role before switching is an original state, the state of the virtual role after switching is a target state, and the original state and the target state are different states. The state switching instruction comprises a state identifier, and the electronic equipment can determine a target state corresponding to the state identifier in response to the state switching instruction. For example, the state identifier in the state switching instruction is a step-down identifier, and the electronic device may determine that the target state is step-down in response to the state switching instruction.
The animation corresponding to the original state is the original state animation, and the electronic equipment plays the original state animation before the state of the virtual character is switched. The raw state animation includes a plurality of consecutive acyclic animation frames. And if the original state comprises repeated loop actions, taking the animation corresponding to a set of loop actions as the original state animation. For example, when the original state is the travel state, an animation corresponding to the virtual character in one cycle of the step circulation motion (i.e., right foot landing, left foot raising → right foot raising, left foot landing → right foot landing, left foot raising, or left foot landing, right foot raising → left foot raising, right foot landing → left foot lowering, right foot raising) is taken as the travel animation.
The original state of the virtual character can be shown by circularly playing the original state animation. That is, the first frame of the original state animation continues to be played after the last frame of the original state animation is played until the state of the virtual character changes. It should be noted that the action of the virtual character in the last frame of the original state animation is consistent or continuous with the action in the first frame, so as to ensure that the display effect of the original state of the virtual character is natural and real.
In the process of playing the original state animation, responding to a state switching instruction aiming at the virtual character, and acquiring the bone position (namely the current bone position) of the virtual character in the original state animation at the current time point. The bone position of the virtual character may be the position of a particular bone of the virtual character, the bone position changing in real-time in the raw state animation. When the origin state is travel, that is, the origin state animation is a travel animation, the bone position of the virtual character may be a foot bone position (including a left foot bone position and/or a right foot bone position), and the foot bone position may be a distance between the foot bone and the ground, including a distance between the left foot bone and the ground and/or a distance between the right foot bone and the ground. .
In one embodiment, an animation frame (current animation frame) corresponding to a current time point in the original state animation is obtained, and the bone position (i.e. the current bone position) of the virtual character in the current animation frame is determined.
In another embodiment, the raw state animation curve is pre-established to determine the current bone position from the raw state animation curve. Specifically, the obtaining the current bone position of the virtual character from the currently played original state animation in step 101 includes: and acquiring the current bone position from a pre-established original state animation curve according to the current time point of the original state animation, wherein the original state animation curve is a relation curve of the bone position and the time point of the virtual character in the original state animation.
When the original state animation curve is established, the bone position in each animation frame of the original state animation can be determined, then the time point of each animation frame (the time point of playing the animation frame in the original state animation) corresponds to the bone position, and all the bone positions are connected into the original state animation curve according to the sequence of the time points. Or, a plurality of key animation frames can be selected from the original state animation, the bone positions in the key animation frames are determined, the time point of each key animation frame corresponds to the bone position, and the connecting line between two adjacent bone positions at the time point is smoothed to obtain an original state animation curve.
When the original state animation curve is established, the original state animation curve can be directly generated according to the corresponding relation between the bone positions and the time points, or the bone positions can be converted into uniform curve values, and the original state animation curve can be generated according to the corresponding relation between the curve values and the time points.
For example, the original state animation is a running animation (e.g., a running animation) corresponding to the virtual character during a round of foot circulation (e.g., right foot landing, left foot lifting → right foot lifting, left foot landing → right foot landing, and left foot lifting) of the virtual character, and the bone position of the virtual character is a foot bone position (e.g., a left foot bone position). As shown in fig. 3, key animation frames are selected from the moving animation, and include a first animation frame (where the right foot lands and the left foot is farthest from the ground) 11, a second animation frame (where the left foot lands and the right foot is farthest from the ground) 12, and a third animation frame (where the right foot lands and the left foot is farthest from the ground) 13. Then, the left foot bone position in the first animation frame 11, the second animation frame 12, and the third animation frame 13 is acquired, and the left foot bone position is converted into a curve value between 0 and 1 such that the curve value when the left foot bone is farthest from the ground is 1 and the curve value when the left foot bone completely contacts the ground is 0. Then, the curve value is associated with the time point, and the connection line between two adjacent left foot bone positions at the time point is smoothed, so as to obtain a traveling animation curve corresponding to the left foot bone, that is, the curve is the corresponding relation curve of the left foot bone position L and the time point t in the traveling animation, as shown in fig. 4. Similarly, the method can also obtain a curve of the moving animation corresponding to the right foot bone, that is, the curve is a corresponding relation curve of the right foot bone position R and the time point t in the moving animation, as shown in fig. 4.
After the original state animation curve is established, responding to a state switching instruction, acquiring a current time point, namely a time point played by the current original state animation, and acquiring a skeleton position corresponding to the current time point from the original state animation curve, wherein the skeleton position is the current skeleton position of the virtual character in the original state animation. As shown in fig. 4, the original state animation curve is a traveling animation curve (including a traveling animation curve corresponding to a left bone and a traveling animation curve corresponding to a right bone), when a state switching instruction is responded, the acquired current time point is t1, the left bone position corresponding to the current time point t1 can be obtained from the traveling animation curve corresponding to the left bone as L1, and the right bone position corresponding to the current time point t1 can be obtained from the traveling animation curve corresponding to the right bone as R1.
It should be noted that the animation curve in the original state needs to be a smooth curve to avoid errors in matching of animation frames during switching of subsequent states, thereby ensuring matching effect.
In the embodiment, the original state animation curve is pre-established, so that when the virtual character needs to be switched over, the current bone position of the virtual character is directly obtained from the pre-established original state animation curve, the bone position in the original state animation does not need to be calculated in real time, and the data calculation amount is effectively reduced.
Step 102, according to the current bone position, determining a playing start frame from a switching animation, wherein the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation.
In this embodiment, the state of the virtual character after switching is the target state, that is, the virtual character can be switched from the original state to the target state, and the animation corresponding to the target state is the target state animation. For example, the original state animation includes a travel animation, and the target state animation includes a turn animation, a stop animation, a jump animation, a crouch animation, or the like. The switch animation may include a transition animation and a target state animation, with the transition animation stitched before the target state animation. The transition animation is used for transition between the original state animation and the target state animation, and the problems of sudden change of motion, blockage and the like when the virtual character is switched from the original state to the target state are avoided.
The transition animation includes at least a portion of the raw state animation, i.e., the transition animation may be a complete raw state animation or may be an animation segment of the raw state animation (i.e., a portion of the raw state animation).
When the transition animation is complete original state animation, the target state may be correspondingly set with a switching animation, that is, the original state animation is spliced before the target state animation to be used as the switching animation. Because the transition animation comprises all animation frames of the animation in the original state, namely the transition animation comprises all actions of the virtual character in the original state, whenever a state switching instruction is triggered, the animation frame (namely the playing start frame) matched with the current animation frame of the animation in the original state can be found from the transition animation, so that the playing start frame is consistent or continuous with the actions of the virtual character in the current animation frame of the animation in the original state.
In order to avoid the overlong duration of the transition animation and ensure that the states of the virtual character can be switched in time, the original state animation can be split into a plurality of animation segments, each animation segment forms a candidate transition animation which is spliced before the target state animation, and a candidate switching animation is formed. That is, different candidate transition animations may be spliced before the target state animation to form different candidate switching animations, so that the target state may set a plurality of candidate switching animations correspondingly, so as to select one candidate switching animation from the plurality of candidate switching animations as the final switching animation.
Specifically, the determining a playing start frame from the switching animation according to the current bone position in step 102 includes: determining the switching animation from a plurality of preset candidate switching animations according to the current bone position, wherein the candidate switching animation comprises candidate transition animations, and the candidate transition animations in the candidate switching animations form the complete original state animation; and determining the playing starting frame from the switching animation according to the current bone position.
The candidate switching animation comprises a target state animation and a candidate transition animation spliced before the target state animation, wherein the candidate transition animation is an animation segment of the original state animation. The candidate transition animations (namely the candidate transition animations in the candidate switching animations) are not overlapped, and the candidate transition animations form a complete original state animation, so that the candidate transition animations comprise all actions of the virtual character in the original state, and whenever a state switching instruction is triggered, an animation frame (namely a play start frame) matched with a current animation frame of the original state animation can be found from one candidate transition animation, so that the play start frame is consistent with or continuous with the actions of the virtual character in the current animation frame of the original state animation.
In one embodiment, a plurality of candidate transition animations may be set according to the bone position of the virtual character in the raw state animation to ensure that the bone positions of the virtual character in the plurality of candidate transition animations are different. After the current bone position of the virtual character in the original state animation is obtained, candidate transition animations matched with the current bone position are found from the candidate transition animations, the candidate transition animations are used as transition animations, and the candidate switching animations to which the candidate transition animations belong are used as switching animations.
Specifically, a candidate switching animation curve is established for each candidate switching animation in advance, and the candidate switching animation curve is a corresponding relation curve of the bone position and the time point of the virtual character in the candidate switching animation. The candidate switching animation curves comprise candidate transition animation curves, and the candidate transition animation curves are corresponding relation curves of the bone positions and time points of the virtual characters in the candidate transition animation. After the current bone position of the virtual character in the original state animation is obtained, a candidate transition animation curve with the current bone position is found from the multiple candidate transition animation curves, the candidate transition animation corresponding to the candidate transition animation curve is used as the transition animation, and the candidate switching animation corresponding to the candidate transition animation curve is used as the switching animation.
In another embodiment, a plurality of candidate transition animations can be set according to the bone position change trend of the virtual character in the original state animation, so as to ensure that the bone position change trends of the virtual character in the plurality of candidate transition animations are different. For example, the original state animation is a running animation, the running animation is split into two animation segments, and two candidate transition animations are correspondingly set according to the two animation segments, namely a first candidate transition animation (such as right foot landing, left foot lifting → right foot lifting, and left foot landing) and a second candidate transition animation (such as right foot lifting, left foot landing → right foot landing, and left foot lifting). When the bone positions include a left foot bone position, the left foot bone position change trend of the first candidate transition animation is downward, and the left foot bone position change trend of the second candidate transition animation is upward. When the bone positions comprise a right foot bone position, the change trend of the right foot bone position of the first candidate transition animation is ascending, and the change trend of the right foot bone position of the second candidate transition animation is descending.
After the current bone position of the virtual character in the original state animation is obtained, the current bone position change trend of the virtual character is determined, candidate transition animations matched with the bone position change trend are determined from a plurality of candidate transition animations, the candidate transition animations are used as transition animations, and the candidate switching animations to which the candidate transition animations belong are used as switching animations.
Specifically, the determining the switching animation from a plurality of preset candidate switching animations according to the current bone position includes: acquiring a previous bone position of the virtual character from the original state animation, wherein the previous bone position is a bone position corresponding to a previous time point of a current time point; determining the current bone position change trend of the virtual character according to the current bone position and the previous bone position; and determining the switching animation from a plurality of preset candidate switching animations according to the bone position change trend.
The previous bone position can be determined directly from the animation frame. Specifically, an animation frame corresponding to a time point before a current time point in the original state animation is obtained, that is, an animation frame before the current animation frame in the original state animation is obtained, and then a bone position (that is, a previous bone position) of the virtual character in the previous animation frame is determined.
The previous bone position may also be obtained by a pre-established raw state animation curve. Specifically, a time point before the current time point is determined from the original-state animation curve, each time point may correspond to an animation frame, and the previous time point may be a time point corresponding to a previous animation frame of the current animation frame. Then, the bone position corresponding to the previous time point (i.e. the previous bone position) is obtained from the original state animation curve. As shown in fig. 4, the original state animation curve is a travel animation curve (including a travel animation curve corresponding to a left bone and a travel animation curve corresponding to a right bone), a previous time point at a current time point t1 is t0, a position of the left bone corresponding to the previous time point t0 is L0, and a position of the right bone corresponding to the previous time point t0 is R0.
And comparing the previous bone position with the current bone position to determine the current bone position change trend of the virtual character in the original state animation. If the current skeleton position is larger than the previous skeleton position, determining that the current skeleton position change trend of the virtual character in the original state animation is rising; and if the current bone position is smaller than the previous bone position, determining that the current bone position change trend of the virtual character in the original state animation is descending.
For example, the bone positions include a left foot bone position and a right foot bone position, and a left foot bone position variation trend and a right foot bone position variation trend may be determined, respectively. As shown in fig. 4, the left foot bone position L1 corresponding to the current time point t1 is smaller than the left foot bone position L0 corresponding to the previous time point t0, and the left foot bone position change trend is a decrease. The right foot bone position L1 corresponding to the current time point t1 is smaller than the right foot bone position L0 corresponding to the previous time point t0, and the change trend of the right foot bone position is rising.
Because the bone position change trends of the virtual character in the candidate transition animations are different, according to the current bone position change trend of the virtual character in the original state animation, a matched candidate transition animation can be found from the candidate transition animations, the candidate transition animation is used as the transition animation, and the candidate switching animation to which the candidate transition animation belongs is used as the switching animation.
Specifically, the determining the switching animation from a plurality of preset candidate switching animations according to the bone position change trend comprises the following steps: determining candidate transition animation curves with curve trends consistent with the bone position change trend from a plurality of pre-established candidate transition animation curves as transition animation curves, wherein the curve trends of the candidate transition animation curves are different, and the candidate transition animation curves are relation curves of the bone positions and time points of the virtual characters in the candidate transition animation; and taking the candidate transition animation corresponding to the transition animation curve as the transition animation, and taking the candidate switching animation to which the transition animation belongs as the switching animation.
And establishing a candidate switching animation curve for each candidate switching animation in advance, wherein the candidate switching animation curve is a corresponding relation curve of the bone position and the time point of the virtual character in the candidate switching animation, and the establishing mode of the candidate switching animation curve is the same as that of the original state animation curve, and the details are not repeated here. The candidate switching animation curves comprise candidate transition animation curves. Due to the fact that the skeleton position change trends in different candidate transition animations are different, curve trends of different candidate transition animation curves are different. And taking the candidate transition animation curve with the curve trend consistent with the current bone position change trend of the virtual character in the original state animation as the transition animation curve.
For example, the origin state animation is a travel animation, the target state animation is a stop animation, and the bone positions of the virtual character are foot bone positions (including a left foot bone position and/or a right foot bone position). Setting a first candidate transition animation (such as right foot landing, left foot lifting → right foot lifting, left foot landing) and a second candidate transition animation (such as right foot lifting, left foot landing → right foot landing, left foot lifting) according to the travel animation. And respectively splicing the first candidate transition animation and the second candidate transition animation before the stop animation to obtain a first candidate switching animation and a second candidate switching animation. As shown in fig. 5, the first candidate switching animation includes a plurality of animation frames, such as a first animation frame (right foot landing, left foot lifting) 21, a second animation frame (right foot lifting, left foot landing) 22, and a third animation frame (right foot landing, left foot landing) 23. Wherein animation frames between the first animation frame 21 and the second animation frame 22 form a first candidate transition animation, and animation frames between the second animation frame 22 and the third animation frame 23 form a stop animation. As shown in fig. 6, the second candidate switching animation includes a plurality of animation frames, such as a first animation frame (left foot landing, right foot lifting) 31, a second animation frame (left foot lifting, right foot landing) 32, and a third animation frame (left foot landing, right foot landing) 33. Wherein animation frames between the first animation frame 31 and the second animation frame 32 constitute a second candidate transition animation, and animation frames between the second animation frame 32 and the third animation frame 33 constitute a stop animation.
It should be noted that, in order to ensure that the target state animation and different candidate transition animations are linked naturally and smoothly, the target state animations in different candidate transition animations may be different but all appear in the same state. For example, the stop animation in the first candidate switching animation in fig. 5 is landed on the left foot first and then landed on the right foot, and the stop animation in the second candidate switching animation in fig. 6 is landed on the right foot first and then landed on the left foot, but both states are stopped.
And respectively establishing a first candidate switching animation curve and a second candidate switching animation curve. As shown in fig. 7, the first candidate switching animation curve may include a first candidate switching animation curve corresponding to a left foot bone (a correspondence curve of a left foot bone position L with a time point t) and a first candidate switching animation curve corresponding to a right foot bone (a correspondence curve of a right foot bone position R with a time point t). The curve corresponding to the time points t2 to t3 in the first candidate switching animation curve is a first candidate transition animation curve, and the curve corresponding to the time points t3 to t4 is a step-stopping animation curve. As can be seen from fig. 7, the curve trend of the first candidate transition animation curve corresponding to the left foot bone is downward, and the curve trend of the first candidate transition animation curve corresponding to the right foot bone is upward. As shown in fig. 8, the second candidate switching animation curves may include a second candidate switching animation curve corresponding to a left foot bone (a correspondence curve of a left foot bone position L with a time point t) and a second candidate switching animation curve corresponding to a right foot bone (a correspondence curve of a right foot bone position R with a time point t). The curve corresponding to the time point t5 to t6 in the second candidate switching animation curve is a second candidate transition animation curve, and the curve corresponding to the time point t6 to t7 is a step-stopping animation curve. As can be seen from fig. 8, the curve trend of the second candidate transition animation curve corresponding to the left foot bone is rising, and the curve trend of the second candidate transition animation curve corresponding to the right foot bone is falling.
And if the current change trend of the left foot bone position of the virtual character in the moving animation is descending and the current change trend of the right foot bone position in the moving animation is ascending, matching the change trend with the curve trend of the first candidate transition animation curve, determining the first candidate transition animation curve as the transition animation curve, taking the candidate transition animation corresponding to the first candidate transition animation curve as the transition animation, and taking the candidate switching animation corresponding to the first candidate transition animation curve as the switching animation.
It should be noted that, if the bone position in the candidate transition animation curve and the bone position in the original state animation curve are the same bone position, for example, the original state animation curve is a correspondence curve of the left foot bone position and the time point, the candidate transition animation curve is also a correspondence curve of the left foot bone position and the time point.
In the embodiment, the animation segments of the animation in the original state are used as the transition animation for switching the animation, so that the smooth movement of the virtual character is ensured, the overlong duration of the transition animation is avoided, the sensitivity of state switching response is improved, and the state of the virtual character can be timely switched. In addition, the setting of the transition animation can improve the sense of reality of state switching, for example, when the virtual character is switched from moving to stopping, the virtual character needs to move forward again due to inertia to stop.
After the switching animation is determined, the playing starting animation frame can be determined from the transition animation of the switching animation. Specifically, the determining a play start frame from the switching animation according to the current bone position includes: acquiring a target time point corresponding to the current bone position from a pre-established transition animation curve, wherein the transition animation curve is a relation curve of the bone position and the time point of the virtual character in the transition animation; and determining a target animation frame corresponding to the target time point from the transition animation, and taking the target animation frame as the playing start frame.
Since the transition animation includes at least a portion of the original state animation, and the transition animation is selected based on the current bone position of the virtual character in the original state animation, the transition animation curve has the current bone position. And acquiring a time point corresponding to the current bone position from the transitional animation curve as a target time point, wherein the target time point is different from the current time point corresponding to the current bone position in the original state animation curve. The target animation frame corresponding to the target time point in the transition animation is the playing start frame, so that the skeleton position of the virtual character in the playing start frame is ensured to be consistent with the current skeleton position of the virtual character in the original state animation, and the action continuity of the virtual character is ensured.
As shown in fig. 7, according to the current foot bone position (including the current left foot bone position L1 and/or the current right foot bone position R1) of the virtual character at the current time point T1 in the moving animation, the target time point corresponding to the current foot bone position may be determined as T from the transition animation curve. And taking the animation frame corresponding to the target time point T in the switching animation as a playing start frame.
And 103, starting to play the switching animation from the playing start frame.
In this embodiment, after the play start frame is determined, the play of the original state animation is switched to the play of the switching animation, and the switching animation starts to be played from the play start frame, so that the virtual character is switched from the original state to the target state, and natural and smooth actions of the virtual character during switching are ensured.
All the above technical solutions can be combined arbitrarily to form the optional embodiments of the present application, and are not described herein again.
According to the state switching method of the virtual character, which is provided by the embodiment of the application, the current bone position of the virtual character is obtained from the currently played original state animation in response to the state switching instruction aiming at the virtual character; determining a playing start frame from a switching animation according to the current bone position, wherein the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation; and starting to play the switching animation from the playing start frame. According to the embodiment of the application, the transition animation is added in the switching animation, so that when the virtual character is subjected to state switching, the animation frame corresponding to the current skeleton position of the virtual character is matched from the transition animation and used as the playing starting frame of the switching animation, the fluency of the action of the virtual character during switching is improved, the reality of the animation expression effect is improved, the matching is performed according to the skeleton position of the virtual character, the posture of the virtual character does not need to be identified, the animation resource amount and the data calculation amount are reduced, and the cost and the performance consumption are further reduced.
The embodiment of the application also provides a virtual role state switching method, which is applied to electronic equipment, wherein the electronic equipment provides a graphical user interface, and the graphical user interface has a virtual role. The specific process of the method can be as follows:
step 201, when it is detected that the virtual character needs to be switched from the advancing mode to the turning mode, determining a current left foot bone position corresponding to a current time point from a pre-established advancing animation curve, wherein the advancing animation curve is a corresponding relation curve of the left foot bone position and the time point of the virtual character in the advancing animation.
The moving animation curve can also be a corresponding relation curve of the position of the right foot bone and the time point.
Step 202, determining a previous left foot bone position corresponding to a previous time point of the current time point from the travel animation curve.
And step 203, comparing the current left foot bone position with the previous left foot bone position, and determining a switching animation from a left foot switching animation and a right foot switching animation according to the comparison result, wherein the left foot switching animation comprises a turning animation and a left foot transition animation spliced before the turning animation, the right foot switching animation comprises the turning animation and a right foot transition animation spliced before the turning animation, and the left foot transition animation and the right foot transition animation form a complete traveling animation.
For example, the motion of the virtual character in the moving animation is right foot landing, left foot lifting → right foot lifting, left foot landing → right foot landing, and left foot lifting, and the moving animation curve is as shown in fig. 4. The moving animation is divided into a left foot transition animation (right foot falling to the ground, left foot rising → right foot rising, left foot falling to the ground) and a right foot transition animation (right foot rising, left foot falling to the ground → right foot falling, left foot rising). The left foot transition animation and the turning animation are spliced into the left foot switching animation, and the right foot transition animation and the turning animation are spliced into the right foot switching animation.
If the current left foot skeleton position is larger than the previous left foot skeleton position, the virtual character in the moving animation is moving forward to the right foot, and the right foot switching animation is selected as switching animation; and if the current left foot bone position is smaller than the previous left foot bone position, which indicates that the virtual character in the moving animation is at the left foot or the right foot, selecting the left foot switching animation as the switching animation.
And step 204, determining a target time point corresponding to the current left foot bone position from a pre-established transition animation curve, wherein the transition animation curve is a corresponding relation curve of the left foot bone position and the time point of the virtual character in the transition animation in the switching animation.
And a left foot switching animation curve and a right foot switching animation curve are established in advance. As shown in fig. 9, the left-foot switching animation curve is a corresponding relationship curve of the left-foot bone position L of the virtual character in the left-foot switching animation and the time point t, and the left-foot transition animation curve is a curve between the time points t8 to t9 in the left-foot switching animation curve. As shown in fig. 10, the right foot switching animation curve is a corresponding relationship curve of the left foot bone position L of the virtual character in the right foot switching animation and the time point t, and the right foot transition animation curve is a curve between the time points t10 to t11 in the right foot switching animation curve.
If the switching animation is left foot switching animation, determining a target time point corresponding to the current bone position from a left foot transition animation curve; and if the switching animation is the right foot switching animation, determining a target time point corresponding to the current bone position from the right foot transition animation curve.
And step 205, starting playing the switching animation from the target time point.
The animation played at present is switched from the advancing animation to the switching animation, and the virtual character can be switched from the advancing animation to the turning-over animation.
The embodiment effectively improves the fluency of the virtual character action during switching, avoids longer transition time during switching, and ensures the sensitivity of operation response. Moreover, the playing position of the animation is matched and switched based on the bone position of the virtual character, so that the animation resource amount and the data calculation amount are reduced, and further the cost and the performance consumption are reduced.
In order to better implement the method for switching the virtual role state according to the embodiment of the present application, an embodiment of the present application further provides a device for switching the virtual role state. Referring to fig. 11, fig. 11 is a schematic structural diagram of a state switching device for virtual roles according to an embodiment of the present application. The virtual role state switching apparatus 300 is applied to an electronic device, the electronic device provides a graphical user interface, the graphical user interface includes a virtual role, and the virtual role state switching apparatus 300 may include an obtaining module 301, a determining module 302, and a playing module 303.
An obtaining module 301, configured to respond to a state switching instruction for the virtual character, and obtain a current bone position of the virtual character from a currently played original state animation;
a determining module 302, configured to determine a play start frame from a switching animation according to the current bone position, where the switching animation includes a target state animation and a transition animation spliced before the target state animation, the transition animation includes at least a part of the original state animation, and the play start frame is an animation frame in the transition animation;
a playing module 303, configured to start playing the switching animation from the playing start frame.
Optionally, the obtaining module 301 is further configured to:
and acquiring the current bone position from a pre-established original state animation curve according to the current time point of the original state animation, wherein the original state animation curve is a relation curve between the bone position of the virtual character in the original state animation and the time point.
Optionally, the determining module 302 is further configured to:
determining the switching animation from a plurality of preset candidate switching animations according to the current bone position, wherein the candidate switching animation comprises candidate transition animations, and the candidate transition animations in the candidate switching animations form the complete original state animation;
and determining the playing start frame from the switching animation according to the current bone position.
Optionally, the determining module 302 is further configured to:
acquiring a previous skeleton position of the virtual character from the original state animation, wherein the previous skeleton position is a skeleton position corresponding to a previous time point of a current time point;
determining the current bone position change trend of the virtual character according to the current bone position and the previous bone position;
and determining the switching animation from a plurality of preset candidate switching animations according to the bone position change trend.
Optionally, the determining module 302 is further configured to:
determining candidate transition animation curves with curve trends consistent with the bone position change trend from a plurality of pre-established candidate transition animation curves as transition animation curves, wherein the curve trends of the candidate transition animation curves are different, and the candidate transition animation curves are relation curves of the bone positions and time points of the virtual characters in the candidate transition animation;
and taking the candidate transition animation corresponding to the transition animation curve as the transition animation, and taking the candidate switching animation to which the transition animation belongs as the switching animation.
Optionally, the determining module 302 is further configured to:
acquiring a target time point corresponding to the current bone position from a pre-established transition animation curve, wherein the transition animation curve is a relation curve of the bone position and the time point of the virtual character in the transition animation;
and determining a target animation frame corresponding to the target time point from the transition animation, and taking the target animation frame as the playing start frame.
Optionally, the original state animation comprises a go animation, and the target state animation comprises a turn animation, a stop animation, a jump animation, a squat animation, or a lie down animation; the skeletal position of the virtual character comprises the distance between the left foot skeleton or the right foot skeleton and the ground.
All the above technical solutions may be combined arbitrarily to form an optional embodiment of the present application, and are not described in detail herein.
The state switching device 300 for a virtual character according to the embodiment of the present application, in response to a state switching instruction for the virtual character, acquires a current bone position of the virtual character from a currently played original state animation; determining a playing start frame from a switching animation according to the current bone position, wherein the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation; and starting to play the switching animation from the play start frame. According to the embodiment of the application, the transition animation is added in the switching animation, so that when the virtual character is subjected to state switching, the animation frame corresponding to the current skeleton position of the virtual character is matched from the transition animation and used as the playing initial frame of the switching animation, the fluency of the action of the virtual character during switching is improved, the reality of the animation expression effect is improved, the matching is performed according to the skeleton position of the virtual character, the posture of the virtual character does not need to be identified, the animation resource amount and the data calculation amount are reduced, and the cost and the performance consumption are further reduced.
Correspondingly, the embodiment of the present application further provides an electronic device, where the electronic device may be a terminal or a server, and the terminal may be a terminal device such as a smart phone, a tablet Computer, a notebook Computer, a touch screen, a game machine, a Personal Computer (PC), a Personal Digital Assistant (PDA), and the like. As shown in fig. 12, fig. 12 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device 400 includes a processor 401 having one or more processing cores, a memory 402 having one or more computer-readable storage media, and a computer program stored on the memory 402 and executable on the processor. The processor 401 is electrically connected to the memory 402. Those skilled in the art will appreciate that the electronic device structures shown in the figures do not constitute limitations on the electronic device, and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The processor 401 is a control center of the electronic device 400, connects various parts of the whole electronic device 400 by using various interfaces and lines, performs various functions of the electronic device 400 and processes data by running or loading software programs and/or modules stored in the memory 402 and calling data stored in the memory 402, thereby performing overall monitoring of the electronic device 400.
In this embodiment, the processor 401 in the electronic device 400 loads instructions corresponding to processes of one or more application programs into the memory 402 according to the following steps, and the processor 401 runs the application programs stored in the memory 402, thereby implementing various functions:
responding to a state switching instruction aiming at the virtual character, and acquiring the current bone position of the virtual character from the currently played original state animation;
determining a playing start frame from a switching animation according to the current bone position, wherein the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation;
and starting to play the switching animation from the play start frame.
Optionally, the obtaining a current bone position of the virtual character from the currently played original state animation includes:
and acquiring the current bone position from a pre-established original state animation curve according to the current time point of the original state animation, wherein the original state animation curve is a relation curve of the bone position and the time point of the virtual character in the original state animation.
Optionally, the determining a play start frame from a switching animation according to the current bone position includes:
determining the switching animation from a plurality of preset candidate switching animations according to the current bone position, wherein the candidate switching animation comprises candidate transition animations, and the candidate transition animations in the candidate switching animations form the complete original state animation;
and determining the playing starting frame from the switching animation according to the current bone position.
Optionally, the determining the switching animation from a preset plurality of candidate switching animations according to the current bone position includes:
acquiring a previous skeleton position of the virtual character from the original state animation, wherein the previous skeleton position is a skeleton position corresponding to a previous time point of a current time point;
determining the current bone position change trend of the virtual character according to the current bone position and the previous bone position;
and determining the switching animation from a plurality of preset candidate switching animations according to the change trend of the bone position.
Optionally, the determining the switching animation from a preset plurality of candidate switching animations according to the bone position variation trend includes:
determining a candidate transition animation curve with the curve trend consistent with the change trend of the bone position from a plurality of pre-established candidate transition animation curves as a transition animation curve, wherein the curve trends of different candidate transition animation curves are different, and the candidate transition animation curve is a relation curve of the bone position of the virtual character in the candidate transition animation and a time point;
and taking the candidate transition animation corresponding to the transition animation curve as the transition animation, and taking the candidate switching animation to which the transition animation belongs as the switching animation.
Optionally, the determining a play start frame from the switching animation according to the current bone position includes:
acquiring a target time point corresponding to the current bone position from a pre-established transition animation curve, wherein the transition animation curve is a relation curve of the bone position and the time point of the virtual character in the transition animation;
and determining a target animation frame corresponding to the target time point from the transition animation, and taking the target animation frame as the playing start frame.
Optionally, the raw state animation comprises a go animation, the target state animation comprises a turn animation, a stop animation, a jump animation, a squat animation, or a lie down animation; the skeletal position of the virtual character comprises the distance between the left foot skeleton or the right foot skeleton and the ground.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Optionally, as shown in fig. 12, the electronic device 400 further includes: touch-sensitive display screen 403, radio frequency circuit 404, audio circuit 405, input unit 406 and power 407. The processor 401 is electrically connected to the touch display 403, the rf circuit 404, the audio circuit 405, the input unit 406, and the power source 407 respectively. Those skilled in the art will appreciate that the electronic device configuration shown in fig. 12 does not constitute a limitation of the electronic device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The touch display screen 403 may be used for displaying a graphical user interface and receiving operation instructions generated by a user acting on the graphical user interface. The touch display screen 403 may include a display panel and a touch panel. The display panel may be used, among other things, to display information entered by or provided to a user and various graphical user interfaces of the electronic device, which may be made up of graphics, text, icons, video, and any combination thereof. Alternatively, the Display panel may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. The touch panel may be used to collect touch operations of a user (for example, operations of the user on or near the touch panel by using a finger, a stylus pen, or any other suitable object or accessory) and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Alternatively, the touch panel may include two parts, a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 401, and can receive and execute commands sent by the processor 401. The touch panel may overlay the display panel, and when the touch panel detects a touch operation thereon or nearby, the touch panel may transmit the touch operation to the processor 401 to determine the type of the touch event, and then the processor 401 may provide a corresponding visual output on the display panel according to the type of the touch event. In the embodiment of the present application, the touch panel and the display panel may be integrated into the touch display screen 403 to realize input and output functions. However, in some embodiments, the touch panel and the touch panel can be implemented as two separate components to perform the input and output functions. That is, the touch display screen 403 may also be used as a part of the input unit 406 to implement an input function.
In the embodiment of the present application, the processor 401 executes road network generation software to generate a graphical user interface on the touch display screen 403. The touch display screen 403 is used for presenting a graphical user interface and receiving an operation instruction generated by a user acting on the graphical user interface.
The rf circuit 404 may be used for transceiving rf signals to establish wireless communication with a network device or other electronic devices via wireless communication, and for transceiving signals with the network device or other electronic devices.
The audio circuit 405 may be used to provide an audio interface between the user and the electronic device through a speaker, microphone. The audio circuit 405 may transmit the electrical signal converted from the received audio data to a speaker, and convert the electrical signal into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 405 and converted into audio data, which is then processed by the audio data output processor 401 and then transmitted to, for example, another electronic device via the rf circuit 404, or the audio data is output to the memory 402 for further processing. The audio circuit 405 may also include an earbud jack to provide communication of a peripheral headset with the electronic device.
The input unit 406 may be used to receive input numbers, character information, or user characteristic information (e.g., fingerprint, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
The power supply 407 is used to power the various components of the electronic device 400. Optionally, the power source 407 may be logically connected to the processor 401 through a power management system, so as to implement functions of managing charging, discharging, power consumption management, and the like through the power management system. The power supply 407 may also include one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, or any other component.
Although not shown in fig. 12, the electronic device 400 may further include a camera, a sensor, a wireless fidelity module, a bluetooth module, etc., which are not described in detail herein.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to the related descriptions of other embodiments.
As can be seen from the above, the electronic device provided in this embodiment, in response to the state switching instruction for the virtual character, acquires the current bone position of the virtual character from the currently played original state animation; determining a playing start frame from a switching animation according to the current bone position, wherein the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation; and starting to play the switching animation from the play start frame. According to the embodiment of the application, the transition animation is added in the switching animation, so that when the virtual character is subjected to state switching, the animation frame corresponding to the current skeleton position of the virtual character is matched from the transition animation and used as the playing initial frame of the switching animation, the fluency of the action of the virtual character during switching is improved, the reality of the animation expression effect is improved, the matching is performed according to the skeleton position of the virtual character, the posture of the virtual character does not need to be identified, the animation resource amount and the data calculation amount are reduced, and the cost and the performance consumption are further reduced.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of computer programs are stored, and the computer programs can be loaded by a processor to execute steps in any one of the screen rendering methods provided in the embodiments of the present application. For example, the computer program may perform the steps of:
responding to a state switching instruction aiming at the virtual character, and acquiring the current bone position of the virtual character from the currently played original state animation;
determining a playing start frame from a switching animation according to the current bone position, wherein the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation;
and starting to play the switching animation from the playing start frame.
Optionally, the obtaining the current bone position of the virtual character from the currently played original state animation includes:
and acquiring the current bone position from a pre-established original state animation curve according to the current time point of the original state animation, wherein the original state animation curve is a relation curve of the bone position and the time point of the virtual character in the original state animation.
Optionally, the determining a play start frame from a switching animation according to the current bone position includes:
determining the switching animation from a plurality of preset candidate switching animations according to the current bone position, wherein the candidate switching animations comprise candidate transition animations, and the candidate transition animations in the candidate switching animations form the complete original state animation;
and determining the playing start frame from the switching animation according to the current bone position.
Optionally, the determining the switching animation from a preset plurality of candidate switching animations according to the current bone position includes:
acquiring a previous bone position of the virtual character from the original state animation, wherein the previous bone position is a bone position corresponding to a previous time point of a current time point;
determining the current bone position change trend of the virtual character according to the current bone position and the previous bone position;
and determining the switching animation from a plurality of preset candidate switching animations according to the bone position change trend.
Optionally, the determining the switching animation from a preset plurality of candidate switching animations according to the bone position variation trend includes:
determining candidate transition animation curves with curve trends consistent with the bone position change trend from a plurality of pre-established candidate transition animation curves as transition animation curves, wherein the curve trends of the candidate transition animation curves are different, and the candidate transition animation curves are relation curves of the bone positions and time points of the virtual characters in the candidate transition animation;
and taking the candidate transition animation corresponding to the transition animation curve as the transition animation, and taking the candidate switching animation to which the transition animation belongs as the switching animation.
Optionally, the determining a play start frame from the switching animation according to the current bone position includes:
acquiring a target time point corresponding to the current bone position from a pre-established transition animation curve, wherein the transition animation curve is a relation curve of the bone position and the time point of the virtual character in the transition animation;
and determining a target animation frame corresponding to the target time point from the transition animation, and taking the target animation frame as the playing start frame.
Optionally, the original state animation comprises a go animation, and the target state animation comprises a turn animation, a stop animation, a jump animation, a squat animation, or a lie down animation; the skeletal position of the virtual character includes a distance of the left foot skeleton or the right foot skeleton from the ground.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Wherein the storage medium may include: read Only Memory (ROM), random Access Memory (RAM), magnetic or optical disks, and the like.
Since the computer program stored in the storage medium can execute the steps in any method for switching the state of the virtual character provided in the embodiment of the present application, beneficial effects that can be achieved by any method for switching the state of the virtual character provided in the embodiment of the present application can be achieved, for details, see the foregoing embodiment, and are not described herein again.
The method, the apparatus, the storage medium, and the electronic device for switching the virtual role states provided in the embodiments of the present application are described in detail above, and specific examples are applied in the present application to explain the principles and embodiments of the present application, and the description of the above embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manner and the application scope may be changed, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method for switching states of virtual roles is characterized in that a graphical user interface is provided through an electronic device, the graphical user interface comprises the virtual roles, and the method comprises the following steps:
responding to a state switching instruction aiming at the virtual character, and acquiring the current bone position of the virtual character from the currently played original state animation;
determining a playing start frame from a switching animation according to the current bone position, wherein the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation;
and starting to play the switching animation from the playing start frame.
2. The method for switching the state of the virtual character according to claim 1, wherein the obtaining the current bone position of the virtual character from the currently played original state animation comprises:
and acquiring the current bone position from a pre-established original state animation curve according to the current time point of the original state animation, wherein the original state animation curve is a relation curve of the bone position and the time point of the virtual character in the original state animation.
3. The method for switching the state of the virtual character according to claim 1, wherein the determining a play start frame from a switching animation according to the current bone position comprises:
determining the switching animation from a plurality of preset candidate switching animations according to the current bone position, wherein the candidate switching animations comprise candidate transition animations, and the candidate transition animations in the candidate switching animations form the complete original state animation;
and determining the playing start frame from the switching animation according to the current bone position.
4. The method of claim 3, wherein the determining the switching animation from a plurality of candidate switching animations according to the current bone position comprises:
acquiring a previous skeleton position of the virtual character from the original state animation, wherein the previous skeleton position is a skeleton position corresponding to a previous time point of a current time point;
determining the current bone position change trend of the virtual character according to the current bone position and the previous bone position;
and determining the switching animation from a plurality of preset candidate switching animations according to the change trend of the bone position.
5. The method for switching the state of a virtual character according to claim 4, wherein the determining the switching animation from a plurality of preset candidate switching animations according to the bone position change trend comprises:
determining candidate transition animation curves with curve trends consistent with the bone position change trend from a plurality of pre-established candidate transition animation curves as transition animation curves, wherein the curve trends of the candidate transition animation curves are different, and the candidate transition animation curves are relation curves of the bone positions and time points of the virtual characters in the candidate transition animation;
and taking the candidate transition animation corresponding to the transition animation curve as the transition animation, and taking the candidate switching animation to which the transition animation belongs as the switching animation.
6. The method for switching the state of the virtual character according to claim 1, wherein the determining a play start frame from the switching animation according to the current bone position comprises:
acquiring a target time point corresponding to the current bone position from a pre-established transition animation curve, wherein the transition animation curve is a relation curve of the bone position and the time point of the virtual character in the transition animation;
and determining a target animation frame corresponding to the target time point from the transition animation, and taking the target animation frame as the playing start frame.
7. The method of switching states of a virtual character according to claim 1, wherein the original state animation includes a progress animation, and the target state animation includes a turn animation, a stop animation, a jump animation, a squat animation, or a lie down animation; the skeletal position of the virtual character includes a distance of the left foot skeleton or the right foot skeleton from the ground.
8. An apparatus for switching states of a virtual character, wherein a graphical user interface is provided by an electronic device, the graphical user interface including the virtual character, the apparatus comprising:
the acquisition module is used for responding to a state switching instruction aiming at the virtual character and acquiring the current bone position of the virtual character from the currently played original state animation;
the determining module is used for determining a playing start frame from a switching animation according to the current bone position, the switching animation comprises a target state animation and a transition animation spliced before the target state animation, the transition animation comprises at least part of the original state animation, and the playing start frame is an animation frame in the transition animation;
and the playing module is used for playing the switching animation from the playing start frame.
9. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program adapted to be loaded by a processor to perform the steps in the method for switching the state of a virtual character according to any one of claims 1 to 7.
10. An electronic device, characterized in that the electronic device comprises a memory in which a computer program is stored and a processor, and the processor executes the steps in the method for switching the state of the virtual character according to any one of claims 1 to 7 by calling the computer program stored in the memory.
CN202211540330.0A 2022-12-02 2022-12-02 Virtual role state switching method and device, storage medium and electronic equipment Pending CN115888101A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211540330.0A CN115888101A (en) 2022-12-02 2022-12-02 Virtual role state switching method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211540330.0A CN115888101A (en) 2022-12-02 2022-12-02 Virtual role state switching method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN115888101A true CN115888101A (en) 2023-04-04

Family

ID=86486603

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211540330.0A Pending CN115888101A (en) 2022-12-02 2022-12-02 Virtual role state switching method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115888101A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117021098A (en) * 2023-08-22 2023-11-10 北京中科深智科技有限公司 Method for generating world-place action based on in-place action

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117021098A (en) * 2023-08-22 2023-11-10 北京中科深智科技有限公司 Method for generating world-place action based on in-place action
CN117021098B (en) * 2023-08-22 2024-01-23 北京中科深智科技有限公司 Method for generating world-place action based on in-place action

Similar Documents

Publication Publication Date Title
CN113398590B (en) Sound processing method, device, computer equipment and storage medium
CN113082688A (en) Method and device for controlling virtual character in game, storage medium and equipment
CN113786620A (en) Game information recommendation method and device, computer equipment and storage medium
CN115040873A (en) Game grouping processing method and device, computer equipment and storage medium
CN115193049A (en) Virtual role control method, device, storage medium and computer equipment
CN115888101A (en) Virtual role state switching method and device, storage medium and electronic equipment
CN113332721A (en) Game control method and device, computer equipment and storage medium
CN115212572A (en) Control method and device of game props, computer equipment and storage medium
CN115501581A (en) Game control method and device, computer equipment and storage medium
CN114225412A (en) Information processing method, information processing device, computer equipment and storage medium
CN113867873A (en) Page display method and device, computer equipment and storage medium
CN113413600A (en) Information processing method, information processing device, computer equipment and storage medium
CN112245914A (en) Visual angle adjusting method and device, storage medium and computer equipment
CN113426121B (en) Game control method, game control device, storage medium and computer equipment
CN115212566A (en) Virtual object display method and device, computer equipment and storage medium
CN115518375A (en) Game word skipping display method and device, computer equipment and storage medium
CN117160031A (en) Game skill processing method, game skill processing device, computer equipment and storage medium
CN115645913A (en) Rendering method and device of game picture, storage medium and computer equipment
CN115554700A (en) Rescue interaction method and device in game, computer equipment and storage medium
CN117861213A (en) Game skill processing method, game skill processing device, computer equipment and storage medium
CN114768252A (en) Game scene display method and device, electronic equipment and storage medium
CN113546413A (en) Method and device for playing open scene, computer readable storage medium and computer equipment
CN115317893A (en) Virtual resource processing method and device, computer equipment and storage medium
CN118179012A (en) Game interaction method, game interaction device, computer equipment and computer readable storage medium
CN114470760A (en) Interaction method and device of virtual props, storage medium and computer equipment

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