CN116501175B - Virtual character moving method, device, computer equipment and medium - Google Patents

Virtual character moving method, device, computer equipment and medium Download PDF

Info

Publication number
CN116501175B
CN116501175B CN202310745931.3A CN202310745931A CN116501175B CN 116501175 B CN116501175 B CN 116501175B CN 202310745931 A CN202310745931 A CN 202310745931A CN 116501175 B CN116501175 B CN 116501175B
Authority
CN
China
Prior art keywords
coordinates
handle
vector
arm
virtual character
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310745931.3A
Other languages
Chinese (zh)
Other versions
CN116501175A (en
Inventor
王晓敏
张琨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangxi Geruling Technology Co ltd
Original Assignee
Jiangxi Geruling Technology 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 Jiangxi Geruling Technology Co ltd filed Critical Jiangxi Geruling Technology Co ltd
Priority to CN202310745931.3A priority Critical patent/CN116501175B/en
Publication of CN116501175A publication Critical patent/CN116501175A/en
Application granted granted Critical
Publication of CN116501175B publication Critical patent/CN116501175B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/011Arrangements for interaction with the human body, e.g. for user immersion in virtual reality
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2203/00Indexing scheme relating to G06F3/00 - G06F3/048
    • G06F2203/01Indexing scheme relating to G06F3/01
    • G06F2203/012Walk-in-place systems for allowing a user to walk in a virtual environment while constraining him to a given position in the physical environment

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the application provides a virtual character moving method, a device, computer equipment and a medium, relating to the technical field of virtual reality, wherein the method comprises the following steps: acquiring handle coordinates and camera coordinates of virtual reality equipment; calculating the swing angle of the arm of the user according to the coordinates of the handle and the coordinates of the camera; starting timing when the arm swing angle reaches a first preset angle, ending timing when the arm swing angle reaches a second preset angle, and recording the time used as the actual swing arm time; calculating the moving speed of the virtual character model corresponding to the current arm swing according to the preset swing arm time, the moving speed initial value and the actual swing arm time; the virtual character model is controlled to move according to the moving speed and the moving direction, wherein the moving direction is the right front of the view angle of the head camera. The virtual character control method of the scheme is simple and easy to operate, so that the control complexity of virtual character movement is reduced, and the user experience is improved.

Description

Virtual character moving method, device, computer equipment and medium
Technical Field
The present application relates to the field of virtual reality technologies, and in particular, to a virtual character movement method, apparatus, computer device, and medium.
Background
With the development of the internet and the market demand, hardware devices are vigorously developed, and software carriers such as PC-VR devices, mobile-end VR devices, MR devices and XR devices of Windows, android, IOS of various systems are various, so that interaction of VR devices is particularly important.
In various interactions of VR devices, character movement is always a non-negligible function, and the manner of character movement directly affects the experience of VR software, so various realization manners of character movement are generated. However, in the prior art, the movement mode of the virtual character is complex, and the movement of the user cannot well control the movement of the virtual character, so that the experience of the user is poor.
Disclosure of Invention
In view of the above, the embodiment of the application provides a virtual character moving method, so as to solve the technical problem that the moving mode of the virtual character in the prior art is complex. The method comprises the following steps:
in a virtual reality scene, acquiring handle coordinates of a handle of the virtual reality device and camera coordinates of a head camera;
according to the handle coordinates and the camera coordinates, calculating an arm swing angle of an arm of a user holding the handle;
starting timing when the arm swinging angle reaches a first preset angle, ending timing when the arm swinging angle reaches a second preset angle, and recording that the used time is the actual swinging arm time;
setting a preset swing arm time and a preset moving speed initial value;
calculating the moving speed of the virtual character model corresponding to the current arm swing according to the preset swing arm time, the moving speed initial value and the actual swing arm time;
and controlling the virtual character model to move according to the moving speed and the moving direction, wherein the moving direction is the right front of the view angle of the head camera.
The embodiment of the application also provides a virtual character moving device, which solves the technical problem that the moving mode of the virtual character in the prior art is complex. The device comprises:
the coordinate acquisition module is used for acquiring handle coordinates of a handle of the virtual reality device and camera coordinates of the head camera in the virtual reality scene;
the first calculation module is used for calculating the arm swing angle of the arm of the user holding the handle according to the handle coordinates and the camera coordinates;
the recording module is used for starting timing when the arm swinging angle reaches a first preset angle, finishing timing when the arm swinging angle reaches a second preset angle, and recording that the used time is the actual swinging arm time;
the setting module is used for setting a preset swing arm time and a preset moving speed initial value;
the second calculation module is used for calculating the moving speed of the virtual character model corresponding to the current arm swing according to the preset swing arm time, the moving speed initial value and the actual swing arm time;
and the control role movement module is used for controlling the virtual role model to move according to the movement speed and the movement direction, wherein the movement direction is right in front of the view angle of the head camera.
The embodiment of the application also provides computer equipment, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the arbitrary virtual character moving method when executing the computer program so as to solve the technical problem of complex virtual character moving mode in the prior art.
The embodiment of the application also provides a computer readable storage medium which stores a computer program for executing the arbitrary virtual character moving method, so as to solve the technical problem that the virtual character moving mode in the prior art is complex.
Compared with the prior art, the beneficial effects that above-mentioned at least one technical scheme that this description embodiment adopted can reach include at least: in a virtual reality scene, acquiring handle coordinates of a handle of the virtual reality device and camera coordinates of a head camera; according to the handle coordinates and the camera coordinates, calculating an arm swinging angle of an arm of a user holding the handle; starting timing when the arm swing angle reaches a first preset angle, ending timing when the arm swing angle reaches a second preset angle, and recording the time used as the actual swing arm time; setting a preset swing arm time and a preset moving speed initial value; calculating the moving speed of the virtual character model corresponding to the current arm swing according to the preset swing arm time, the moving speed initial value and the actual swing arm time; the virtual character model is controlled to move according to the moving speed and the moving direction, wherein the moving direction is the right front of the view angle of the head camera. The movement speed of the virtual character is calculated and controlled by the arm swing angle and the arm swing time which are calculated according to the acquired handle coordinates and camera coordinates, and the movement speed of the virtual character can be further controlled by controlling the movement speed of the arm swing.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a virtual character movement method according to an embodiment of the present application;
FIG. 2 is a block diagram of a computer device according to an embodiment of the present application;
fig. 3 is a block diagram of a virtual character moving apparatus according to an embodiment of the present application.
Detailed Description
Embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Other advantages and effects of the present application will become apparent to those skilled in the art from the following disclosure, which describes the embodiments of the present application with reference to specific examples. It will be apparent that the described embodiments are only some, but not all, embodiments of the application. The application may be practiced or carried out in other embodiments that depart from the specific details, and the details of the present description may be modified or varied from the spirit and scope of the present application. It should be noted that the following embodiments and features in the embodiments may be combined with each other without conflict. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the embodiment of the application, a virtual character movement method is provided, which is a character movement method in VR equipment based on Unity development, and the method is mainly used for realizing the action of simulating the arm swing of a person when walking, mapping the action to the character movement in the VR equipment, namely, the arm swing is carried out by holding a handle in the VR equipment, so as to control the virtual character in a virtual reality scene to move. Unity is a cross-platform 2D/3D game engine developed by Unity Technologies, which takes an interactive graphical development environment as a primary mode, and a compiler runs under Windows and Mac OS X to release games to multiple platforms such as Windows, wii, OSX, iOS or HTML 5.
Therefore, the present application provides a virtual character moving method, which is developed based on a Unity development platform, as shown in fig. 1, and the method comprises:
step S1, in a virtual reality scene, acquiring handle coordinates of a handle of virtual reality equipment and camera coordinates of a head camera;
s2, calculating an arm swing angle of an arm of a user holding the handle according to the handle coordinates and the camera coordinates;
step S3, starting timing when the arm swing angle reaches a first preset angle, finishing timing when the arm swing angle reaches a second preset angle, and recording the time used as the actual swing arm time;
s4, setting a preset swing arm time and a preset moving speed initial value;
s5, calculating the moving speed of the virtual character model corresponding to the current arm swing according to the preset swing arm time, the moving speed initial value and the actual swing arm time;
and S6, controlling the virtual character model to move according to the moving speed and the moving direction, wherein the moving direction is right in front of the view angle of the head camera.
In the above embodiment, the arm swing angle is calculated by the acquired handle coordinates and camera coordinates, and the movement speed of the virtual character is calculated by the arm swing angle and the swing arm time, and when the arm swing is fast, the movement of the virtual character is fast, and when the arm swing is slow, the movement of the virtual character is slow. Therefore, the virtual character can be controlled to move only by swinging the arm, and the moving speed of the virtual character is controlled by swinging the arm, so that the virtual character control method is simple and easy to operate, and the user experience is improved.
In implementation, the handle coordinates of the current handle and the camera coordinates of the head camera are obtained through an SDK in the VR device, wherein the SDK can be VRTK or PicoSDK and the like.
In practice, the movement speed of the corresponding virtual character model when each arm swings is calculated by the following formula:
moving speed = preset swing arm time/actual swing arm time per arm x coefficient x initial value of moving speed, wherein the coefficient is an adjustable coefficient. The initial value of the moving speed defaults to an initial value, for example, set to 0.5m/s, representing 0.5m of movement per second; the coefficient is an adjustable coefficient, the coefficient is used for adjusting the final moving speed of the virtual character, the default is 1, other values can be adjusted according to the preference of an operator, and when the coefficient is increased, the virtual character controlled to move faster than the condition of swinging the arm when the coefficient is set to be 1.
In a specific implementation, the calculating, according to the handle coordinates and the camera coordinates, an arm swing angle of an arm of a user holding the handle includes:
calculating a first vector formed between the handle and the user's shoulder and a second vector parallel to the user's body according to the handle coordinates and the camera coordinates;
and calculating a first included angle formed between the first vector and the second vector, wherein the first included angle is the arm swinging angle.
In a specific implementation, the calculating a first vector formed between the handle and the shoulder of the user according to the handle coordinates and the camera coordinates includes:
subtracting the camera coordinates from the handle coordinates to obtain a vector line01 of the handle to the user's head;
acquiring a unilateral vector line_X of a head of a user, wherein the unilateral vector line_X of the head and the handle are on the same side;
calculating a second included angle between the line01 and the line_X according to a dot product formula;
coordinates (x 3, y3, z 3) of point01 in the same plane as the current handle and at the same height as the user's shoulder are calculated as:
(X3, y3, z 3) = (X1, y1, z 1) + (line_x X second included angle) - (0, y4, 0),
wherein y4 is a preset vertical distance from the head of the user to the shoulder of the user, and (x 1, y1, z 1) is the handle coordinate;
calculating the first vector according to the coordinates of the handle and the coordinates of the point01, wherein the first vector is a vector of the handle pointing to the point 01;
calculating the second vector parallel to the user's body, comprising:
selecting point02 at a first preset distance vertically downward from the point 01;
and calculating the second vector according to the coordinates of the point01 and the coordinates of the point02, wherein the second vector is a vector of the point02 pointing to the point 01.
In one embodiment, when the user controls the virtual character to move by holding the handle with the right hand, the preset vertical distance from the user's head to the user's shoulder is 0.2m, and it should be noted that the preset vertical distance from the user's head to the user's shoulder may be adjusted according to the actual requirement, and is not limited to the numerical values listed in the embodiment.
First, a first vector dir_01 formed between the handle and the user's shoulder is calculated from the right handle coordinates and the camera coordinates, including: subtracting the camera coordinates from the right handle coordinates to obtain a vector line01 from the right handle to the head of the user; the method comprises the steps of obtaining a unilateral vector line_X of a head of a user, wherein the handle is a right handle, so that the unilateral vector line_X of the head is a right vector line_R of the head at the moment, and when the method is implemented, the right vector line_R of the head is obtained through an algorithm head.transform.right.normal; calculating a second included angle a of the line01 and the line_R according to an algorithm vector3.Dot (line 01, line_R) of the dot product formula; coordinates (x 3, y3, z 3) of point01 in the same plane as the current handle and at the same height as the user's shoulder are calculated as:
(x3,y3,z3)=(x1,y1,z1)+(line_R×a)-(0,y4,0),
wherein y4 is the vertical distance from the head of the user to the shoulder of the user, which is preset, 0.2m, (x 1, y1, z 1) is the right handle coordinate; and calculating a first vector dir_01 according to the coordinates of the right handle and the coordinates of the point01, wherein the first vector dir_01 is the vector of the right handle pointing to the point 01.
Second, a second vector dir_02 parallel to the user's body is calculated, comprising: selecting point02 at a first preset distance vertically downward from point 01; the second vector dir_02 is calculated according to the coordinates of the point01 and the coordinates of the point02, where dir_02 is the vector of the point02 pointing to the point01, in this embodiment, the point02 is selected at a first preset distance 0.3m vertically downward from the point01, where the purpose of selecting the point02 is to construct a vector parallel to the user's body, and therefore, the value of the first preset distance is not limited to the one listed in this embodiment, and may be adjusted to other values.
Finally, the right arm swing angle is calculated by the algorithm vector3.Angle (dir_01, dir_02) of the dot product formula.
By the calculation method in the embodiment, the coordinates (shoulder coordinates) of the points which are on the same plane with the handle and are at the same height as the shoulders of the user can be calculated by the handle coordinates and the camera coordinates, the first vector of the handle pointing to the shoulders is obtained by the handle coordinates and the shoulder coordinates, and the second vector parallel to the body is obtained by the shoulder coordinates, so that the arm swinging angle can be accurately calculated.
In particular, in order to prevent the situation that the movement of the virtual character can be triggered by the arm swing after the lifting of the handle, the movement range of the handle is limited, so that the virtual character movement method further comprises the following steps:
detecting a distance between the coordinates of the handle and the coordinates of the point01 in a direction parallel to the body of the user;
if the distance is smaller than the second preset distance, stopping calculating the moving speed of the virtual character model corresponding to the arm swing at the moment;
and if the distance is greater than or equal to a second preset distance, calculating the first vector according to the coordinates of the handle and the coordinates of the point 01.
For example, the second preset distance is set to 20 cm, and if the distance between the coordinates of the handle and the coordinates of the point01 in the direction parallel to the body of the user is less than 20 cm, this indicates that the handle is lifted too high at this time, not the back-and-forth swing of the arm, and therefore, in order to avoid the movement of the virtual character caused by the lifting of the handle, it is necessary to stop calculating the movement speed of the virtual character model corresponding to this swing of the arm at this time, that is, the movement of the arm at this time does not control the movement of the virtual character. By limiting the movement range of the handle, the handle can be prevented from being lifted to trigger the movement of the virtual character, so that the accuracy of controlling the movement of the virtual character through arm swing is improved.
In particular, in order to obtain effective arm swing, the virtual character movement method further includes the following steps:
and when the movement speed of the virtual character model is calculated, if the actual swing arm time is greater than the preset swing arm time and/or the arm swing angle does not reach the second preset angle, stopping calculating the movement speed of the virtual character model corresponding to the arm swing.
For example, the first preset angle of arm swing is selected to be 5 °, the second preset angle is selected to be 30 °, and the preset swing arm time is 3 seconds. When the arm swing is detected to reach 5 degrees, starting timing, and stopping timing when the arm swing is detected to reach 30 degrees, wherein the period of time is the actual swing arm time of the arm swing, if the actual swing arm time is too long and exceeds the upper limit of the effective time (exceeds the preset swing arm time for 3 seconds), the arm swing is considered to be invalid, the detection is stopped, and the virtual character does not move; if the swing of the arm to 30 DEG is not detected from the time when the arm swings to 5 DEG to the time when the preset swing arm time is 3 seconds, the swing arm movement is not effective, the detection is stopped, and the virtual character does not move. Therefore, only if the arm swing is completed within a prescribed time, and the swing arm height, i.e., the height of the handle coordinates cannot be higher than the height of the shoulder coordinates during this time, calculation of the moving speed and direction is started. According to the embodiment, the time limit and the angle limit of the arm swing are set, so that the accuracy of controlling the movement of the character through the arm swing is further improved, and the experience of a user is improved.
In the practical implementation, in the process of actually operating the handles, the virtual character movement can be controlled by operating the handles by a single hand, or the virtual character movement can be controlled by taking one handle by two hands respectively, if the virtual character model movement is controlled by alternately swinging the two arms, the movement speed of the virtual character model corresponding to each arm swinging is calculated respectively, the movement speeds of the virtual character models corresponding to the two arms swinging are added and summed, the virtual character model is controlled to move once by utilizing the summed movement speed, and the movement direction is the right front of the visual angle of the head camera, namely the absolute vector of the front vector of the camera coordinates plus the camera coordinates. Wherein the moving speed of the corresponding virtual character model when each arm swings is calculated by the following formula:
moving speed = preset swing arm time/actual swing arm time per arm x coefficient x initial value of moving speed, wherein the coefficient is an adjustable coefficient.
The movement of the virtual character is controlled through the swinging of the two arms, so that the movement speed of the virtual character can be improved, the problem that a user needs to quickly move the virtual character when using the virtual character can be solved, the convenience of changing the movement speed of the virtual character is improved, meanwhile, the user can save the swinging arm action, the time and the labor are saved, and the user experience is improved.
In particular, the movement time of the virtual character controlled by each arm swing can be adjusted according to the actual situation, for example, the virtual character moves for 1 second at the calculated movement speed after each arm swing, and the movement is stopped after 1 second is finished.
It should be noted that the arm swing angle calculated by us is the angle between the arm and the body, so the arm can swing forward or backward. The faster the arm swings, the faster the virtual character moves, if multiple swinging arms are performed within 1 second of the movement of the virtual character, if the calculated speeds are (1.2 m/s,1.3m/s,1.4 m/s), the current moving speed will be superimposed multiple times, and the moving speed calculated by each swinging arm, i.e. the total moving speed is 1.2+1.3+1.4=3.9 m/s, but the time of the moving speed calculated by each swinging arm is only one second, and the moving speed of the swinging arm after one second is subtracted from the total moving speed, i.e. when the moving speed of 1.2m/s lasts for 1 second, the current moving speed is 3.9-1.2=2.7 m/s, and so on.
In a specific implementation, since the coordinates of the handle and the coordinates of the camera are obtained based on the coordinate system, the coordinate system is required to be set up before the coordinates are obtained, and the virtual character moving method further comprises the following steps:
establishing a three-dimensional coordinate system in a virtual reality scene, selecting a certain point in the virtual reality scene as an origin of the three-dimensional coordinate system, selecting one direction on a horizontal plane in the virtual reality scene as an X axis of the three-dimensional coordinate system, and taking a direction vertical to the horizontal plane upwards as a Y axis of the three-dimensional coordinate system;
calculating a Z axis of the three-dimensional coordinate system according to the X axis and the Y axis by adopting a right-hand spiral rule;
the handle coordinates and the camera coordinates are extracted from the three-dimensional coordinate system.
Only one three-dimensional coordinate system in the Unity development platform is the world coordinate system, the Unity is equivalent to a small world, and the coordinates of the object are called world coordinates. It takes a certain point of the virtual reality scene (for example, the center point of the scene) as an origin, takes a fixed direction (usually an upward direction, also called an "upper axis") as a Y-axis, takes a direction on the horizontal plane of the scene as an X-axis, calculates a Z-axis from the two axes, and uses the same world coordinate system for all game objects. We need to acquire the real world coordinates of the handgrip (handgrip coordinates) and the real world coordinates of the head camera (camera coordinates) through the world coordinate system as initial data of the character in the virtual scene for calculating the arm swing angle.
In this embodiment, a computer device is provided, as shown in fig. 2, including a memory 201, a processor 202, and a computer program stored on the memory and executable on the processor, where the processor implements any of the virtual character movement methods described above when executing the computer program.
In particular, the computer device may be a computer terminal, a server or similar computing means.
In the present embodiment, there is provided a computer-readable storage medium storing a computer program for executing any of the above-described virtual character movement methods.
In particular, computer-readable storage media, including both permanent and non-permanent, removable and non-removable media, may be used to implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer-readable storage media include, but are not limited to, phase-change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable storage media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
Based on the same inventive concept, the embodiment of the application also provides a virtual character moving device, as described in the following embodiment. Since the principle of the virtual character moving apparatus for solving the problem is similar to that of the virtual character moving method, the implementation of the virtual character moving apparatus can refer to the implementation of the virtual character moving method, and the repetition is not repeated. As used below, the term "unit" or "module" may be a combination of software and/or hardware that implements the intended function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
Fig. 3 is a block diagram of a virtual character moving apparatus according to an embodiment of the present application, as shown in fig. 3, including: the configuration is described below with reference to the coordinate acquisition module 301, the first calculation module 302, the recording module 303, the setting module 304, the second calculation module 305, and the control character movement module 306.
A coordinate acquiring module 301, configured to acquire, in a virtual reality scene, a handle coordinate of a handle of a virtual reality device and a camera coordinate of a head camera;
the first calculating module 302 is configured to calculate an arm swing angle of an arm of a user holding the handle according to the handle coordinates and the camera coordinates;
the recording module 303 is configured to start timing when the arm swing angle reaches a first preset angle, end timing when the arm swing angle reaches a second preset angle, and record the time used as the actual swing arm time;
the setting module 304 is used for setting a preset swing arm time and a preset moving speed initial value;
a second calculating module 305, configured to calculate a movement speed of the virtual character model corresponding to the current arm swing according to the preset swing arm time, the initial movement speed value, and the actual swing arm time;
and a control character movement module 306 for controlling the movement of the virtual character model according to the movement speed and the movement direction, wherein the movement direction is the right front of the view angle of the head camera.
In implementation, the first computing module 302 is further configured to:
calculating a first vector formed between the handle and the user's shoulder and a second vector parallel to the user's body according to the handle coordinates and the camera coordinates;
and calculating a first included angle formed between the first vector and the second vector, wherein the first included angle is the arm swinging angle.
In particular implementations, the first computing module 302 includes a first vector computing module and a second vector computing module, the first vector computing module configured to:
subtracting the camera coordinates from the handle coordinates to obtain a vector line01 of the handle to the user's head;
acquiring a unilateral vector line_X of a head of a user, wherein the unilateral vector line_X of the head and the handle are on the same side;
calculating a second included angle between the line01 and the line_X according to a dot product formula;
coordinates (x 3, y3, z 3) of point01 in the same plane as the current handle and at the same height as the user's shoulder are calculated as:
(X3, y3, z 3) = (X1, y1, z 1) + (line_x X second included angle) - (0, y4, 0),
wherein y4 is a preset vertical distance from the head of the user to the shoulder of the user, and (x 1, y1, z 1) is the handle coordinate;
and calculating the first vector according to the coordinates of the handle and the coordinates of the point01, wherein the first vector is a vector of the handle pointing to the point 01.
The second vector calculation module is used for:
selecting point02 at a first preset distance vertically downward from the point 01;
and calculating the second vector according to the coordinates of the point01 and the coordinates of the point02, wherein the second vector is a vector of the point02 pointing to the point 01.
In specific implementation, the device further comprises a handle position judging module for:
detecting a distance between the coordinates of the handle and the coordinates of the point01 in a direction parallel to the body of the user;
if the distance is smaller than the second preset distance, stopping calculating the moving speed of the virtual character model corresponding to the arm swing at the moment;
and if the distance is greater than or equal to a second preset distance, calculating the first vector according to the coordinates of the handle and the coordinates of the point 01.
In specific implementation, the device further comprises a moving speed stop calculation judging module, which is used for:
and when the movement speed of the virtual character model is calculated, if the actual swing arm time is greater than the preset swing arm time and/or the arm swing angle does not reach the second preset angle, stopping calculating the movement speed of the virtual character model corresponding to the arm swing.
In specific implementation, the device further comprises a moving speed summation module for:
if the two arms swing alternately to control the movement of the virtual character model, respectively calculating the movement speed of the virtual character model corresponding to each arm swinging, adding and summing the movement speeds of the virtual character models corresponding to the two arms swinging, and controlling the virtual character model to move once by using the summed movement speeds, wherein the movement speed of the virtual character model corresponding to each arm swinging is calculated by the following formula:
moving speed = preset swing arm time/actual swing arm time per arm x coefficient x initial value of moving speed, wherein the coefficient is an adjustable coefficient.
In specific implementation, the device further comprises a three-dimensional coordinate system establishing module for:
establishing a three-dimensional coordinate system in a virtual reality scene, selecting a certain point in the virtual reality scene as an origin of the three-dimensional coordinate system, selecting one direction on a horizontal plane in the virtual reality scene as an X axis of the three-dimensional coordinate system, and taking a direction vertical to the horizontal plane upwards as a Y axis of the three-dimensional coordinate system;
calculating a Z axis of the three-dimensional coordinate system according to the X axis and the Y axis by adopting a right-hand spiral rule;
the handle coordinates and the camera coordinates are extracted from the three-dimensional coordinate system.
The embodiment of the application realizes the following technical effects: in a virtual reality scene, acquiring handle coordinates of a handle of the virtual reality device and camera coordinates of a head camera; according to the handle coordinates and the camera coordinates, calculating an arm swinging angle of an arm of a user holding the handle; starting timing when the arm swing angle reaches a first preset angle, ending timing when the arm swing angle reaches a second preset angle, and recording the time used as the actual swing arm time; setting a preset swing arm time and a preset moving speed initial value; calculating the moving speed of the virtual character model corresponding to the current arm swing according to the preset swing arm time, the moving speed initial value and the actual swing arm time; the virtual character model is controlled to move according to the moving speed and the moving direction, wherein the moving direction is the right front of the view angle of the head camera. The movement speed of the virtual character is calculated and controlled by the arm swing angle and the arm swing time which are calculated according to the acquired handle coordinates and camera coordinates, and the movement speed of the virtual character can be further controlled by controlling the movement speed of the arm swing.
It will be apparent to those skilled in the art that the modules or steps of the embodiments of the application described above may be implemented in a general purpose computing device, they may be concentrated on a single computing device, or distributed across a network of computing devices, they may alternatively be implemented in program code executable by computing devices, so that they may be stored in a storage device for execution by computing devices, and in some cases, the steps shown or described may be performed in a different order than what is shown or described, or they may be separately fabricated into individual integrated circuit modules, or a plurality of modules or steps in them may be fabricated into a single integrated circuit module. Thus, embodiments of the application are not limited to any specific combination of hardware and software.
The above description is only of the preferred embodiments of the present application and is not intended to limit the present application, and various modifications and variations can be made to the embodiments of the present application by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (8)

1. A virtual character movement method, comprising:
in a virtual reality scene, acquiring handle coordinates of a handle of the virtual reality device and camera coordinates of a head camera;
according to the handle coordinates and the camera coordinates, calculating an arm swing angle of an arm of a user holding the handle, including: calculating a first vector formed between the handle and the user's shoulder and a second vector parallel to the user's body according to the handle coordinates and the camera coordinates; calculating a first included angle formed between the first vector and the second vector, wherein the first included angle is the arm swing angle;
starting timing when the arm swinging angle reaches a first preset angle, ending timing when the arm swinging angle reaches a second preset angle, and recording that the used time is the actual swinging arm time;
setting a preset swing arm time and a preset moving speed initial value;
calculating the moving speed of the virtual character model corresponding to the current arm swing according to the preset swing arm time, the moving speed initial value and the actual swing arm time;
controlling the virtual character model to move according to the moving speed and the moving direction, wherein the moving direction is right in front of the view angle of the head camera;
wherein the calculating a first vector formed between the handle and a user's shoulder from the handle coordinates and the camera coordinates comprises:
subtracting the camera coordinates from the handle coordinates to obtain a vector line01 of the handle to the user's head;
acquiring a unilateral vector line_X of a head of a user, wherein the unilateral vector line_X of the head and the handle are on the same side;
calculating a second included angle between the line01 and the line_X according to a dot product formula;
coordinates (x 3, y3, z 3) of point01 in the same plane as the current handle and at the same height as the user's shoulder are calculated as:
(X3, y3, z 3) = (X1, y1, z 1) + (line_x X second included angle) - (0, y4, 0),
wherein y4 is a preset vertical distance from the head of the user to the shoulder of the user, and (x 1, y1, z 1) is the handle coordinate;
calculating the first vector according to the coordinates of the handle and the coordinates of the point01, wherein the first vector is a vector of the handle pointing to the point 01;
calculating the second vector parallel to the user's body, comprising:
selecting point02 at a first preset distance vertically downward from the point 01;
and calculating the second vector according to the coordinates of the point01 and the coordinates of the point02, wherein the second vector is a vector of the point02 pointing to the point 01.
2. The virtual character movement method according to claim 1, wherein the method further comprises:
detecting a distance between the coordinates of the handle and the coordinates of the point01 in a direction parallel to the body of the user;
if the distance is smaller than the second preset distance, stopping calculating the moving speed of the virtual character model corresponding to the arm swing at the moment;
and if the distance is greater than or equal to a second preset distance, calculating the first vector according to the coordinates of the handle and the coordinates of the point 01.
3. The virtual character movement method according to any one of claims 1 to 2, wherein the method further comprises:
and when the movement speed of the virtual character model is calculated, if the actual swing arm time is greater than the preset swing arm time and/or the arm swing angle does not reach the second preset angle, stopping calculating the movement speed of the virtual character model corresponding to the arm swing.
4. The virtual character movement method according to any one of claims 1 to 2, wherein the method further comprises:
if the two arms swing alternately to control the movement of the virtual character model, respectively calculating the movement speed of the virtual character model corresponding to each arm swinging, adding and summing the movement speeds of the virtual character models corresponding to the two arms swinging, and controlling the virtual character model to move once by using the summed movement speeds, wherein the movement speed of the virtual character model corresponding to each arm swinging is calculated by the following formula:
moving speed = preset swing arm time/actual swing arm time per arm x coefficient x initial value of moving speed, wherein the coefficient is an adjustable coefficient.
5. The virtual character movement method according to any one of claims 1 to 2, wherein the method further comprises:
establishing a three-dimensional coordinate system in a virtual reality scene, selecting a certain point in the virtual reality scene as an origin of the three-dimensional coordinate system, selecting one direction on a horizontal plane in the virtual reality scene as an X axis of the three-dimensional coordinate system, and taking a direction vertical to the horizontal plane upwards as a Y axis of the three-dimensional coordinate system;
calculating a Z axis of the three-dimensional coordinate system according to the X axis and the Y axis by adopting a right-hand spiral rule;
the handle coordinates and the camera coordinates are extracted from the three-dimensional coordinate system.
6. A virtual character movement apparatus, comprising:
the coordinate acquisition module is used for acquiring handle coordinates of a handle of the virtual reality device and camera coordinates of the head camera in the virtual reality scene;
the first calculation module is configured to calculate an arm swing angle of an arm of a user holding the handle according to the handle coordinates and the camera coordinates, and includes: calculating a first vector formed between the handle and the user's shoulder and a second vector parallel to the user's body according to the handle coordinates and the camera coordinates; calculating a first included angle formed between the first vector and the second vector, wherein the first included angle is the arm swing angle;
the recording module is used for starting timing when the arm swinging angle reaches a first preset angle, finishing timing when the arm swinging angle reaches a second preset angle, and recording that the used time is the actual swinging arm time;
the setting module is used for setting a preset swing arm time and a preset moving speed initial value;
the second calculation module is used for calculating the moving speed of the virtual character model corresponding to the current arm swing according to the preset swing arm time, the moving speed initial value and the actual swing arm time;
a control character movement module for controlling the movement of the virtual character model according to the movement speed and the movement direction, the movement direction being right in front of the view angle of the head camera;
wherein the calculating a first vector formed between the handle and a user's shoulder from the handle coordinates and the camera coordinates comprises:
subtracting the camera coordinates from the handle coordinates to obtain a vector line01 of the handle to the user's head;
acquiring a unilateral vector line_X of a head of a user, wherein the unilateral vector line_X of the head and the handle are on the same side;
calculating a second included angle between the line01 and the line_X according to a dot product formula;
coordinates (x 3, y3, z 3) of point01 in the same plane as the current handle and at the same height as the user's shoulder are calculated as:
(X3, y3, z 3) = (X1, y1, z 1) + (line_x X second included angle) - (0, y4, 0),
wherein y4 is a preset vertical distance from the head of the user to the shoulder of the user, and (x 1, y1, z 1) is the handle coordinate;
calculating the first vector according to the coordinates of the handle and the coordinates of the point01, wherein the first vector is a vector of the handle pointing to the point 01;
calculating the second vector parallel to the user's body, comprising:
selecting point02 at a first preset distance vertically downward from the point 01;
and calculating the second vector according to the coordinates of the point01 and the coordinates of the point02, wherein the second vector is a vector of the point02 pointing to the point 01.
7. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the virtual character movement method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for executing the virtual character movement method according to any one of claims 1 to 5.
CN202310745931.3A 2023-06-25 2023-06-25 Virtual character moving method, device, computer equipment and medium Active CN116501175B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310745931.3A CN116501175B (en) 2023-06-25 2023-06-25 Virtual character moving method, device, computer equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310745931.3A CN116501175B (en) 2023-06-25 2023-06-25 Virtual character moving method, device, computer equipment and medium

Publications (2)

Publication Number Publication Date
CN116501175A CN116501175A (en) 2023-07-28
CN116501175B true CN116501175B (en) 2023-09-22

Family

ID=87325010

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310745931.3A Active CN116501175B (en) 2023-06-25 2023-06-25 Virtual character moving method, device, computer equipment and medium

Country Status (1)

Country Link
CN (1) CN116501175B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117180752B (en) * 2023-11-07 2024-01-26 北京格如灵科技有限公司 Method, device, computer equipment and medium for controlling movement of control object model

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106354256A (en) * 2016-08-28 2017-01-25 杭州勺子网络科技有限公司 Moving control method of virtual reality
CN106354250A (en) * 2016-08-05 2017-01-25 广东欧珀移动通信有限公司 Method and device for setting step counting parameters and terminal
CN106814851A (en) * 2016-12-09 2017-06-09 武汉秀宝软件有限公司 A kind of augmented reality exchange method and system
CN107102725A (en) * 2017-03-09 2017-08-29 国网山东省电力公司济宁供电公司 A kind of control method and system that virtual reality movement is carried out based on somatosensory handle
JP6220473B1 (en) * 2017-04-04 2017-10-25 株式会社コロプラ Method for providing virtual space, program for realizing the method in a computer, recording medium recording the program, and system for providing virtual space
KR101830793B1 (en) * 2016-09-07 2018-02-21 한국해양과학기술원 virtual training system using upper body interaction
WO2018141928A1 (en) * 2017-02-06 2018-08-09 Raptor Lab Sarl Method and system for moving a virtual character in a virtual environment
CN108762495A (en) * 2018-05-18 2018-11-06 深圳大学 The virtual reality driving method and virtual reality system captured based on arm action
WO2020017440A1 (en) * 2018-07-17 2020-01-23 株式会社Univrs Vr device, method, program and recording medium
CN110780738A (en) * 2019-10-17 2020-02-11 深圳市创凯智能股份有限公司 Virtual reality simulation walking method, device, equipment and readable storage medium
CN116196611A (en) * 2023-02-27 2023-06-02 深圳十米网络科技有限公司 Somatosensory game method based on waving action

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010118552A1 (en) * 2009-04-15 2010-10-21 Yu Juntao Treadmill utilizing man-machine interactive mode for controlling speed and control method thereof
US20180224930A1 (en) * 2015-08-04 2018-08-09 Board Of Regents Of The Nevada System Of Higher Education, On Behalf Of The University Of Nevada, Immersive virtual reality locomotion using head-mounted motion sensors
WO2017213218A1 (en) * 2016-06-10 2017-12-14 株式会社コロプラ Method for providing virtual space, program for causing computer to implement said method, and system for providing virtual space
US20220365588A1 (en) * 2019-09-04 2022-11-17 Sony Group Corporation Information processing apparatus, information processing method, and program

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106354250A (en) * 2016-08-05 2017-01-25 广东欧珀移动通信有限公司 Method and device for setting step counting parameters and terminal
CN106354256A (en) * 2016-08-28 2017-01-25 杭州勺子网络科技有限公司 Moving control method of virtual reality
KR101830793B1 (en) * 2016-09-07 2018-02-21 한국해양과학기술원 virtual training system using upper body interaction
CN106814851A (en) * 2016-12-09 2017-06-09 武汉秀宝软件有限公司 A kind of augmented reality exchange method and system
WO2018141928A1 (en) * 2017-02-06 2018-08-09 Raptor Lab Sarl Method and system for moving a virtual character in a virtual environment
CN107102725A (en) * 2017-03-09 2017-08-29 国网山东省电力公司济宁供电公司 A kind of control method and system that virtual reality movement is carried out based on somatosensory handle
JP6220473B1 (en) * 2017-04-04 2017-10-25 株式会社コロプラ Method for providing virtual space, program for realizing the method in a computer, recording medium recording the program, and system for providing virtual space
CN108762495A (en) * 2018-05-18 2018-11-06 深圳大学 The virtual reality driving method and virtual reality system captured based on arm action
WO2020017440A1 (en) * 2018-07-17 2020-01-23 株式会社Univrs Vr device, method, program and recording medium
CN110780738A (en) * 2019-10-17 2020-02-11 深圳市创凯智能股份有限公司 Virtual reality simulation walking method, device, equipment and readable storage medium
CN116196611A (en) * 2023-02-27 2023-06-02 深圳十米网络科技有限公司 Somatosensory game method based on waving action

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Complementary spatial and timing control in rhythmic arm movements;Nickl, Robert W.等;JOURNAL OF NEUROPHYSIOLOGY;全文 *
基于可变形运动模型的多角色语义化运动合成;王鑫;陈秋迪;梁朝凯;王万良;;计算机科学(第10期);全文 *
面向多用户协同的机场应急救援虚拟演练进程控制研究;王蓝;中国优秀硕士学位论文全文数据库 工程科技Ⅱ辑;全文 *

Also Published As

Publication number Publication date
CN116501175A (en) 2023-07-28

Similar Documents

Publication Publication Date Title
US10282882B2 (en) Augmented reality simulation continuum
CN116501175B (en) Virtual character moving method, device, computer equipment and medium
CN106582012B (en) Climbing operation processing method and device under a kind of VR scene
JP6690014B2 (en) Head mounted display tracking
WO2022193612A1 (en) Motion processing method and apparatus for game character, and storage medium and computer device
CN110141862B (en) Method and device for mobile control in game, electronic equipment and storage medium
CN105807931A (en) Realization method of virtual reality
US20130154974A1 (en) Input direction determination system, terminal server, network system, information storage medium, and input direction determination method
CN108245890B (en) Method and device for controlling movement of object in virtual scene
CN108230429A (en) Real-time whole body posture reconstruction method based on head and two-hand positions and posture
WO2023088041A1 (en) Method and apparatus for generating walking animation of virtual character, and device and storage medium
JP6864753B2 (en) Object movement method and device, storage medium, electronic device
WO2022127241A1 (en) Virtual-sphere deformation control method, apparatus, program, and readable medium
US11112857B2 (en) Information processing apparatus, information processing method, and program
CN110111411A (en) A kind of browse processing method and device of threedimensional model
CN111265874B (en) Method, device, equipment and storage medium for modeling target object in game
US11875094B2 (en) Minimization function for friction solving
CN110930488B (en) Fish behavior simulation method, device, equipment and storage medium
CN111443812A (en) Free movement method based on VR, VR device, equipment and storage medium
WO2021055052A1 (en) Inertia scaling based on neighboring bodies
CN107516327B (en) Method, device and equipment for determining camera attitude matrix based on multilayer filtering
CN115629670B (en) Method, device, equipment and medium for displaying hand gesture in virtual reality environment
CN107564058B (en) Object position display method and device
CN107704165B (en) Virtual lens control method and device, storage medium and electronic equipment
JP5784985B2 (en) Program, information storage medium, information processing system, and information processing method

Legal Events

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