Jump to content

Character system architecture


photo

Recommended Posts

Hello.

 

I want create character system (Character system from <scripts/character/character.h> not match), so I use character code for write my own simple Character system. So I have some questions:

1. Why initCharacter() declared outer of class Character, it's doing cause uinigine have not static function declaration, and it's using like static function?

 

namespace Unigine {

/******************************************************************************\
 *
 * public
 *
\******************************************************************************/

/*
 */
void initCharacter() {

	initAnimationTree();

}

 

2. This is instead super.update(dt)?

void update(float dt) {

Unigine::Character::update(dt);

  • Like 1
Link to comment

Hi Eugene,

 

1. These are intentionally outside of the Character class. They are to be called prior to using the Character system because they set up the input, events, combiner factories so that when loading, they can properly parse and construct objects from XML.

 

2. Unigine does not use completely C++ syntax. They use Unigine::Character::update() for example to call a super class's method.

I have a post on this and callback functions declared with the same syntax being able to locate a specific instance of a class and call its member function.

It seems Unigine script has some unique features. I'm still not fully clear on how exactly it all works. But, I use it :)

 

By the way, it seems like you're doing a project very similar to mine (using many of the same features as me )

I have an animation editor tool (see in the Showcase forum), which is used for animation blending for the Unigine Character system.

Let me know if you'd be interested in using it.

 

 

Good luck!

  • Like 1
Link to comment

Thanks for answer. Now I have one another question )

 

I create robot.character with next animation graph:

<animation_graph>

	<!-- CharacterBase / torso -->
	<combiner type="blend">
		<inputs>
			<input name="weight" type="const">0.5</input>
		</inputs>
		<flows>
			<!-- turning -->
			<flow>
				<combiner type="grid">
					<inputs>
						<input name="pos_x" type="function" shift="90" min="0" max="180" smooth="400">Source::CharacterBase::getYaw</input>
						<input name="pos_y" type="function" shift="90" min="0" max="180" smooth="400">Source::CharacterBase::getPitch</input>
					</inputs>

					<events>
						<event on="blend_in_finish" callback="Source::Character::setShootEnabled">
							<arg type="const">1</arg>
						</event>
						<event on="blend_out_start" callback="Source::Character::setShootEnabled">
							<arg type="const">0</arg>
						</event>
					</events>

					<grid num_keys_x="3" num_keys_y="2" max_x="180" max_y="180">

						<key pos_x="0" pos_y="0">
							<combiner type="animation">
								<inputs>
									<input name="speed" type="const">5</input>
								</inputs>
								<animation start="0" end="-1">source/animation/robot_turn_center_left_pose.sanim</animation>
							</combiner>
						</key>
						<key pos_x="1" pos_y="0">
							<combiner type="animation">
								<inputs>
									<input name="speed" type="const">5</input>
								</inputs>
								<animation start="0" end="-1">robot_center_center.sanim</animation>
							</combiner>
						</key>
						<key pos_x="2" pos_y="0">
							<combiner type="animation">
								<inputs>
									<input name="speed" type="const">5</input>
								</inputs>
								<animation start="0" end="-1">source/animation/robot_turn_center_right_pose.sanim</animation>
							</combiner>
						</key>

						<key pos_x="0" pos_y="1">
							<combiner type="animation">
								<inputs>
									<input name="speed" type="const">5</input>
								</inputs>
								<animation start="0" end="-1">source/animation/robot_turn_top_left_pose.sanim</animation>
							</combiner>
						</key>
						<key pos_x="1" pos_y="1">
							<combiner type="animation">
								<inputs>
									<input name="speed" type="const">5</input>
								</inputs>
								<animation start="0" end="1">source/animation/robot_center_center.sanim</animation>
							</combiner>
						</key>
						<key pos_x="2" pos_y="1">
							<combiner type="animation">
								<inputs>
									<input name="speed" type="const">5</input>
								</inputs>
								<animation start="0" end="-1">source/animation/robot_turn_top_right_pose.sanim</animation>
							</combiner>
						</key>

					</grid>
				</combiner>
			</flow>
			<!-- idle animation -->
			<flow>
				<combiner type="animation">
					<inputs>
						<input name="speed" type="const">0</input>
					</inputs>
					<animation start="0" end="-1" speed="15">source/animation/robot_idle.sanim</animation>
				</combiner>
			</flow>
		</flows>
	</combiner>

</animation_graph>

 

Target of this graph is: character can turn left, right, turn up left, up right, and he has an idle animation. I use Grid 3x2 for blending this directions and use Blend for blending this result with idle animation. Is it graph correct? Cause character turning if I change yaw/pitch variables, but idle-component of animation is not visible.

  • Like 1
Link to comment
×
×
  • Create New...