Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (NewbieZorro, Grant, TipmyPip, AndrewAMD), 12,885 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
How do i pick up and carry a "box" and then set it down agian? #267480
05/24/09 09:44
05/24/09 09:44
Joined: Mar 2006
Posts: 321
Norway
Eagelina Offline OP
Senior Member
Eagelina  Offline OP
Senior Member

Joined: Mar 2006
Posts: 321
Norway
I am now trying to make this:
player go and pick up a box/key , and then carry it visble to another point and then set it down.


But how /what type of code do I need for carry a object visible from one place to another?
I have this code for picking up a key from aum 78, it works fine.
Code:
//attach to they keys you whant to use
action my_key()

{


       set(my, PASSABLE);

       while (!player) {wait (1);} // wait until the player is loaded

       while (vec_dist (player.x, my.x) > 50) // this loop runs until the player picks up the key

       {        

               my.pan += 5 * time_step; // 5 gives the rotation speed of the key

               wait (1);
               
//						
       }

       // the player has got the key here

       got_key += 1; //add 1 key more
       
wait(1);

       set(my, INVISIBLE);
       

}



A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
Re: How do i pick up and carry a "box" and then set it down agian? [Re: Eagelina] #267483
05/24/09 11:02
05/24/09 11:02
Joined: Apr 2009
Posts: 298
Southern Oceans
KiwiBoy Offline
Member
KiwiBoy  Offline
Member

Joined: Apr 2009
Posts: 298
Southern Oceans
You need to set against vertices or a set height and distance from player or whatever is picking it up.

So sort out how you are going to do that first.

Next, you need to set to the position same as you would when glueing camera to player with vec_set.
Then you need to tell it that it moves with you, via offset (checkout thanks (tanks) in one of the earlier Aums for attaching rotating gun barrel to tank) and my.frame.

Verice attach is solid and if you tit, the box has to as well, so you need to make it do that too. smile


Use the 'manual' Luke, the manual is your friend. 'Self reminder' smile

My WebPage
Re: How do i pick up and carry a "box" and then set it down agian? [Re: Eagelina] #267502
05/24/09 15:02
05/24/09 15:02
Joined: Mar 2006
Posts: 321
Norway
Eagelina Offline OP
Senior Member
Eagelina  Offline OP
Senior Member

Joined: Mar 2006
Posts: 321
Norway
How about using physics? Is that an alternative? And how is that used to make that happend: pick up a box carry it and set it down.


A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
Re: How do i pick up and carry a "box" and then set it down agian? [Re: Eagelina] #267695
05/25/09 23:02
05/25/09 23:02
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

I use : vec_for_vertex

I find in MED the position of the vertex that I want and
then in the code

vec_for_vertex (ent_that_picksup,entity,165);

Hope this helps smile
Ottawa

Re: How do i pick up and carry a "box" and then set it down agian? [Re: Ottawa] #267700
05/25/09 23:28
05/25/09 23:28
Joined: Apr 2009
Posts: 298
Southern Oceans
KiwiBoy Offline
Member
KiwiBoy  Offline
Member

Joined: Apr 2009
Posts: 298
Southern Oceans
First player gets close to 'box',
If(vec_dist(my.x, your.x < 40;//if player comes as close as 40 quants
box.x = player.x +20;//offset 20 quants in front of player
box.y = player.y;
box.z = player.z + 2;//offset a bit upwards (from origin of model)
my.frame = your.frame;/when player moves, the 'box' moves too in the same frame
my.next_frame = your. next_frame;//when player moves in the next frame, 'box' moves with it.

The BOX that was on the ground must be deleted as soon as the pick up is made.

Hope thios helps....


Use the 'manual' Luke, the manual is your friend. 'Self reminder' smile

My WebPage
Re: How do i pick up and carry a "box" and then set it down agian? [Re: KiwiBoy] #267706
05/25/09 23:43
05/25/09 23:43
Joined: Jul 2008
Posts: 223
Pittsburgh
The_Clyde Offline
Member
The_Clyde  Offline
Member

Joined: Jul 2008
Posts: 223
Pittsburgh
If the box's only purpose in "life" is to get picked up, the code could consist of simply a while loop that wait(1)'s until vec_dist(my.x,player.x) < 150 or so, and then it sets havebox = 1 and ent_remove's itself.

Another function, perhaps the player function, would have some code in its loop that always keeps an invisible and passable copy of the box attached to the player, and makes the box visible if(havebox == 1)

This also means that if you wanted other things to respond to the box being picked up, all you would have to do is add an if(havebox == 1) to their function.

Re: How do i pick up and carry a "box" and then set it down agian? [Re: KiwiBoy] #267774
05/26/09 07:52
05/26/09 07:52
Joined: Mar 2006
Posts: 321
Norway
Eagelina Offline OP
Senior Member
Eagelina  Offline OP
Senior Member

Joined: Mar 2006
Posts: 321
Norway
@Ottawa I whant to make a more flexible code so that I can use it everywhere. But thanks for the suggestion. It is so interesting to see what you al suggest. It helps a lot grin

@KiwiBoy I like your suggestion and made this action.

It works fine when it comes to pick up the box.

But when I turn around with it it kind of turn inside the player. And stays there until I turn again. How do I fix that?

And how do I make the player leave the box afther he has carried it to the place I whant?

Here are my action so far:
Code:
action my_box()
{

       while (!player) {wait (1);} // wait until the player is loaded

       while (vec_dist (player.x, my.x) >20) // this loop runs until the player picks up the box

       {        

		my.x = player.x +50;
      my.y =player.y;
      my.z =player.z +50;



if(key_l)//leave the box here
{
	//here I whant to be able to set the box down and leave it
	//maybee use vec_dist(player.x,my.x)>-200);//so the player cant "feel" the box  ????
	//then some code for leaving the box here......
	 set(my, INVISIBLE);//test if the program reacts
	 
}

               wait (1);
              	
       }


}


Last edited by Eagelina; 05/26/09 07:55.

A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
Re: How do i pick up and carry a "box" and then set it down agian? [Re: Eagelina] #267776
05/26/09 08:07
05/26/09 08:07
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
In my signature there is the link to an ingame tutorial that explains exactly such functions, but it is with A5. Nonetheless, the principles didn't change.

Re: How do i pick up and carry a "box" and then set it down agian? [Re: Pappenheimer] #267783
05/26/09 08:29
05/26/09 08:29
Joined: Mar 2006
Posts: 321
Norway
Eagelina Offline OP
Senior Member
Eagelina  Offline OP
Senior Member

Joined: Mar 2006
Posts: 321
Norway
Thanks! I did download it now, and are going to "dig" into it during the day. Just love this...lol.... so interesting.... in danger of sounding like a litle child in a candy store. I just love to find out how things work..... blush


A6 and A7 Commercial
-------------------
Programmer always searching for more to learn and understand. smile
Re: How do i pick up and carry a "box" and then set it down agian? [Re: Eagelina] #267787
05/26/09 08:47
05/26/09 08:47
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
wink
F1 to toggle between help screen and world when you are close to an object, the arrows on the patches to scroll or change the page.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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