Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, SBGuy, Petra), 801 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Enemy bend at waist #455582
10/24/15 11:26
10/24/15 11:26
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I am trying to make it so that an enemy will bend at the waist as needed, to always have its upper body facing the player.

So for example, if the player is walking up stairs, and the enemy attacks the player from up the stairs, the enemy should bend forward at the waist so that its upper body is facing down directly toward the player.

I am assuming that ent_bonerotate() would be used for this? I am trying to make this happen, but so far it is not working. This is the code I have so far:

Code:
action monster_code()
{
   ...

   ent_bonereset(my,"waist");

   ...

   while(1)
   {
      ...

      limit=clamp(camera.tilt,-53,53); //min max
      ent_bonerotate(my, "waist", vector(0,limit,0));

      wait(1);
   }
}



I am assuming that I have to somehow manipulate the ent_bonerotate() function to make it so the enemy is bending at the waist, where its upper body is continually facing the player at all times while attacking.

Does anyone have a clue on how I could start on doing this?

Last edited by Ruben; 10/24/15 11:38.
Re: Enemy bend at waist [Re: Ruben] #455583
10/24/15 13:44
10/24/15 13:44
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi,
reading 23rd workshop would take you some doubts off.

Originally Posted By: Online Tutorial - Workshop 23: Bones
Why do we need to reset the bone first? Let's assume that bone_angle.pan is set to 30 degrees at a certain moment. Then, let's imagine that the player moves the mouse a little further in the following frame, until bone_angle.pan reaches 35 degrees. But the gun was already rotated by 30 degrees in the previous frame, so it would now rotate another 35 degrees, setting the pan angle to 30 + 35 = 65 degrees!

This is what would happen if we wouldn't use that "ent_bonereset" instruction inside the while loop. By using ent_bonereset we discard the old angles every frame, so the bone will only get the newly computed angles (pan = 35 degrees in my previous example)


Salud!

Re: Enemy bend at waist [Re: txesmi] #455586
10/24/15 16:44
10/24/15 16:44

M
Malice
Unregistered
Malice
Unregistered
M



http://www.conitec.net/beta/avec_to_angle.htm

vec_to_angle (ANGLE* ang, VECTOR* dir);
Computes the pan and tilt angles of a direction vector, and places them into the pan and tilt parameters of an Euler angle. Very useful for trading an angle for a direction, thus computing the angles to a target.

Code:
function turn_towards_target()
{
  // get the direction from the entity MY to the entity YOU
  vec_set(temp,your.x); 
  vec_sub(temp,my.x);
  vec_to_angle(my.pan,temp); // now MY looks at YOU
}



Code:
action monster_code()
{
   ...
   VECTOR vec_temp;
   VECTOR vec_bend;
   var limit2=0;
   var limit3=0;  

   ...

   while(1)
   {
      ...
       // get the direction from the entity MY to the entity YOU
  vec_set(vec_temp,player.x); 
  vec_sub(vec_temp,my.x);
  if(abs(vec_bend.pan) >90)
  vec_to_angle(vector(my.pan,0,0),vec_temp); // now MY
else
{
vec_to_angle(vec_bend,vec_temp); // now MY looks at YOU
       ent_bonereset(my,"waist");
      limit=clamp(vec_bend.tilt,-53,53); //min max
      limit2=clamp(vec_bend.pan,-90,90); //min max
      limit3=clamp(vec_bend.roll,-25,25); //min max
      ent_bonerotate(my, "waist", vector(limit2,limit,limit3));
}
      wait(1);
   }
}



When do we start getting paid for this?

Lol , have fun
Mal

EDITED- Code correction

Last edited by Malice; 10/24/15 16:54.
Re: Enemy bend at waist [Re: ] #455595
10/25/15 05:21
10/25/15 05:21
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: Malice
http://www.conitec.net/beta/avec_to_angle.htm

vec_to_angle (ANGLE* ang, VECTOR* dir);
Computes the pan and tilt angles of a direction vector, and places them into the pan and tilt parameters of an Euler angle. Very useful for trading an angle for a direction, thus computing the angles to a target.

Code:
function turn_towards_target()
{
  // get the direction from the entity MY to the entity YOU
  vec_set(temp,your.x); 
  vec_sub(temp,my.x);
  vec_to_angle(my.pan,temp); // now MY looks at YOU
}



Code:
action monster_code()
{
   ...
   VECTOR vec_temp;
   VECTOR vec_bend;
   var limit2=0;
   var limit3=0;  

   ...

   while(1)
   {
      ...
       // get the direction from the entity MY to the entity YOU
  vec_set(vec_temp,player.x); 
  vec_sub(vec_temp,my.x);
  if(abs(vec_bend.pan) >90)
  vec_to_angle(vector(my.pan,0,0),vec_temp); // now MY
else
{
vec_to_angle(vec_bend,vec_temp); // now MY looks at YOU
       ent_bonereset(my,"waist");
      limit=clamp(vec_bend.tilt,-53,53); //min max
      limit2=clamp(vec_bend.pan,-90,90); //min max
      limit3=clamp(vec_bend.roll,-25,25); //min max
      ent_bonerotate(my, "waist", vector(limit2,limit,limit3));
}
      wait(1);
   }
}



When do we start getting paid for this?

Lol , have fun
Mal

EDITED- Code correction


Error in ''monsterCode.c'
'pan': is not a member of 'VECTOR'
< if(abs(vec_bend.pan) >90)
>

Re: Enemy bend at waist [Re: txesmi] #455597
10/25/15 05:56
10/25/15 05:56
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: txesmi
Hi,
reading 23rd workshop would take you some doubts off.

Originally Posted By: Online Tutorial - Workshop 23: Bones
Why do we need to reset the bone first? Let's assume that bone_angle.pan is set to 30 degrees at a certain moment. Then, let's imagine that the player moves the mouse a little further in the following frame, until bone_angle.pan reaches 35 degrees. But the gun was already rotated by 30 degrees in the previous frame, so it would now rotate another 35 degrees, setting the pan angle to 30 + 35 = 65 degrees!

This is what would happen if we wouldn't use that "ent_bonereset" instruction inside the while loop. By using ent_bonereset we discard the old angles every frame, so the bone will only get the newly computed angles (pan = 35 degrees in my previous example)


Salud!


I tried incorporating this code:

Code:
action monster_code()
{
   ...

   ent_bonereset(my,"waist");

   ...

   while(1)
   {
      ...

      ent_bonerotate(my, "waist", vector(0, player, 0));

      wait(1);
   }
}



The monster charges toward me using the above code. It seems to be bending the monster's waist. However, the monster's waist is bent all the way back when charging the player, when the monster should bend a little forward to face its upper body toward the player and strike the player, since the monster is taller than the player.

I tried changing this line in the above code:

Code:
ent_bonerotate(my, "waist", vector(0, player, 0));



to:

Code:
ent_bonerotate(my, "waist", vector(0, player.tilt, 0));



or

Code:
ent_bonerotate(my, "waist", vector(0, player.y, 0));



When I do either of these two options, the monster_code() action crashes when I run the game. It does not crash when I use the original code.

Last edited by Ruben; 10/25/15 06:01.
Re: Enemy bend at waist [Re: Ruben] #455609
10/25/15 18:29
10/25/15 18:29

M
Malice
Unregistered
Malice
Unregistered
M



Code:
Error in ''monsterCode.c'
'pan': is not a member of 'VECTOR'
< if(abs(vec_bend.pan) >90)
>


You should know how to fix this.!
Change vec_bend.pan to vec_bend.x
pan is a member of ANGLE
x is a member of VECTOR

Re: Enemy bend at waist [Re: ] #455610
10/25/15 18:37
10/25/15 18:37

M
Malice
Unregistered
Malice
Unregistered
M



Quote:
Originally Posted By: txesmi
Hi,
reading 23rd workshop would take you some doubts off.

Originally Posted By: Online Tutorial - Workshop 23: Bones
Why do we need to reset the bone first? Let's assume that bone_angle.pan is set to 30 degrees at a certain moment. Then, let's imagine that the player moves the mouse a little further in the following frame, until bone_angle.pan reaches 35 degrees. But the gun was already rotated by 30 degrees in the previous frame, so it would now rotate another 35 degrees, setting the pan angle to 30 + 35 = 65 degrees!

This is what would happen if we wouldn't use that "ent_bonereset" instruction inside the while loop. By using ent_bonereset we discard the old angles every frame, so the bone will only get the newly computed angles (pan = 35 degrees in my previous example)


Salud!


I tried incorporating this code:

Code:
action monster_code()
{
...

ent_bonereset(my,"waist");

...

while(1)
{
...

ent_bonerotate(my, "waist", vector(0, player, 0));

wait(1);
}
}



The monster charges toward me using the above code. It seems to be bending the monster's waist. However, the monster's waist is bent all the way back when charging the player, when the monster should bend a little forward to face its upper body toward the player and strike the player, since the monster is taller than the player.

I tried changing this line in the above code:

Code:
ent_bonerotate(my, "waist", vector(0, player, 0));



to:

Code:
ent_bonerotate(my, "waist", vector(0, player.tilt, 0));



or

Code:
ent_bonerotate(my, "waist", vector(0, player.y, 0));



When I do either of these two options, the monster_code() action crashes when I run the game. It does not crash when I use the original code.



First like i did in my code and txesmi is telling add ent_bonerest inside the while() loop.

Next you first try you passed a pointer into the tilt value of the ent_bonerotate( .....vector(0,player,0)...) God knows what the value of the pointer was

Next in the second - This one should not crash - ent_bonerotate(my,"waist", vector(0, player.tilt, 0));
However it shouldn't work the way you want.

It may be that if the last to are failing the the pointer "player" is not assigned. Crashing makes no sense - these just should not work the way you want.

Re: Enemy bend at waist [Re: ] #455611
10/25/15 18:40
10/25/15 18:40

M
Malice
Unregistered
Malice
Unregistered
M



ANGLE VECTOR
pan == x
tilt == y
roll == z


"Mans reach exceeds his grasp"

Sorry to tell you, but you should take a week or two to study, if you do not know what is and how to use pointers, ANGLE and VECTOR.

I learned by seeing post then trying to figure out how to fix the issues. You're not asking for a little help, your're asking people to write code for things you haven't even learned.


Last edited by Malice; 10/25/15 18:45.
Re: Enemy bend at waist [Re: ] #455619
10/25/15 22:08
10/25/15 22:08
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: Malice
ANGLE VECTOR
pan == x
tilt == y
roll == z


"Mans reach exceeds his grasp"

Sorry to tell you, but you should take a week or two to study, if you do not know what is and how to use pointers, ANGLE and VECTOR.

I learned by seeing post then trying to figure out how to fix the issues. You're not asking for a little help, your're asking people to write code for things you haven't even learned.


I thank you for your help, but just for your information, I have never asked anyone to write code for me. You chose to do that on your own.

Bones is also a new topic for me, and I am seeking to understand it better.

Thank you for the advice on angle versus vector. It helped me understand it better.

Last edited by Ruben; 10/25/15 22:41.
Re: Enemy bend at waist [Re: Ruben] #455624
10/25/15 22:46
10/25/15 22:46

M
Malice
Unregistered
Malice
Unregistered
M



It's not your lack of bone knowledge, it's your lack of understanding vector, angle and pointers.

As for writing code, well it's just easier then 3-4 days of posting back in fourth.

I could have said

// find the player in ang space
vec_to_angle(.....);
//check if player is more then 90* +- me
if(abs(vec_bend.x>90)
... turn my pan to face player
// Else - bend my body to face player
ent_bonerest(...)
...fill limit1, limit2 limit3 from vec_bend.xyz
ent_bonerotate(.....vector(limit1,limit2,limit3)...);


However then I would have days of questions. It's just a observation.
Good luck have fun.
Mal

Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1