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
2 registered members (AndrewAMD, TipmyPip), 12,420 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
Rating: 5
Pushing. #316883
03/27/10 14:27
03/27/10 14:27
Joined: Feb 2010
Posts: 6
D
dirt Offline OP
Newbie
dirt  Offline OP
Newbie
D

Joined: Feb 2010
Posts: 6
I have a group of spaceships that move to where the mouse is clicke; the smaller ships will stop when colliding with the larger ships and will wait for them to continue; I was wondering how to use the push value to cause the larger ships to push the smaller ones out of the way.

Re: Pushing. [Re: dirt] #316985
03/28/10 13:30
03/28/10 13:30
Joined: Mar 2009
Posts: 11
-
T
tehVolcano Offline
Newbie
tehVolcano  Offline
Newbie
T

Joined: Mar 2009
Posts: 11
-
You should use the physics engine to do that for you. Instead of using c_move, try this:

Code:
action spaceship()
{
	phent_settype(me,PH_RIGID,PH_BOX);
	phent_setmass(me,1000);
	phent_setdamping(me,0,0);
	phent_enable(me,1);
	//All your spaceship code.
}


You should use the physics engine to do that for you. Instead of using c_move, try this:

Code:
action spaceship()
{
	phent_settype(me,PH_RIGID,PH_BOX); //Turn the ship into a physics entity
	phent_setmass(me,1000); //Set the mass, bigger ships should have a higher mass.
	phent_setdamping(me,100,100); //Set the damping, angular and linear...
	phent_enable(me,1); //Turn on physics engine for this ship.
	//All your spaceship code.
}



Then, for setting the rotation of the spaceships, simply do this:

Code:
//code before setting rotation
	phent_enable(me,0); //Allow manual position and rotation changes
	wait(1); //Wait one frame to make sure the changes are actually made
	//Set pan, tilt, roll
	wait(1); //Wait one frame to prevent glitches
	phent_enable(me,1); //Enable physics for the ship
	//Code after rotating



To move the spaceships, use the phent_addvellocal function.

Code:
phent_addvellocal(me,vector(0,-20,0),vector(0,0,0));



Be sure not to change the second vector, else your spaceship will fly a curve. The second vector is like the thruster position, and the thruster should be in the center of the ship for optimal flight behaviour.
Also, if the ship flies sideways, try
Code:
phent_addvellocal(me,vector(-20,0,0),vector(0,0,0));



Also, I guess you don't want any gravity. Put this into function main:
Code:
ph_setgravity(vector(0,0,0)); //Zero gravity




Gamestudio A7 Pro
Re: Pushing. [Re: tehVolcano] #316986
03/28/10 13:35
03/28/10 13:35
Joined: Mar 2009
Posts: 11
-
T
tehVolcano Offline
Newbie
tehVolcano  Offline
Newbie
T

Joined: Mar 2009
Posts: 11
-
I forgot to mention that phent_setdamping(me,100,100); causes the ship to stop moving or rotating unless a force acts on it. If you use values lower than 100, the ships will take some time to slow down, and if you use 0, then the entity will keep going on forever until it collides with something else, or you apply a force to it.


Gamestudio A7 Pro
Re: Pushing. [Re: tehVolcano] #317067
03/29/10 05:00
03/29/10 05:00
Joined: Feb 2010
Posts: 6
D
dirt Offline OP
Newbie
dirt  Offline OP
Newbie
D

Joined: Feb 2010
Posts: 6
I never considered using the physics engine; the solution that I was looking for was a simple way of calculating the absolute move vector during c_move; the usual method won't work because all of the spaceships only move forward; but ok, I guess I'll have to figure it out on my own.

Re: Pushing. [Re: dirt] #317073
03/29/10 07:18
03/29/10 07:18
Joined: Mar 2010
Posts: 120
Switzerland
T
TehV Offline
Member
TehV  Offline
Member
T

Joined: Mar 2010
Posts: 120
Switzerland
The advantage of using the physics engine, however, is that it saves you a lot of time when coding, because it does do a lot for you. It is a lot easier to just use physics than it is to use C_move and push.

Re: Pushing. [Re: TehV] #317074
03/29/10 07:21
03/29/10 07:21
Joined: Mar 2010
Posts: 120
Switzerland
T
TehV Offline
Member
TehV  Offline
Member
T

Joined: Mar 2010
Posts: 120
Switzerland
You could use the IGNORE_PUSH mode in c_move, but that will allow the larger ships to pass through the smaller ships. I don't think you'd want that.

Re: Pushing. [Re: TehV] #317142
03/29/10 14:45
03/29/10 14:45
Joined: Feb 2010
Posts: 6
D
dirt Offline OP
Newbie
dirt  Offline OP
Newbie
D

Joined: Feb 2010
Posts: 6
There isn't really any advantage, I just couldn't figure it out. Recently, I have figured out a solution; I was using two fail safes during the ship movement, the sticking only really occurs when the ships are organizing into a formation, when they bump into each other, the smaller entity is pushed out of the way and will wait for the larger ship to move into formation.


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