Calling touch on a decoration

Discussions about Coding and Scripting
Post Reply
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Calling touch on a decoration

Post by JackGriffin »

In a nutshell here's what I want to do. I want to spawn a pylon that can be bumped around the map to place it correctly but once you jump onto it:

Code: Select all

if (Other.Physics == PHYS_Falling)
	  Other.Velocity.Z += 600;
you get flung into the air. I'll be damned if I can get the fling to work though. Something in the touch/bump on the deco mesh is cancelling out the added z. Now I know it's working because I've logged it out. Also I've seen this in MH play: books that you can chainsaw and ride into space, trees that act as cannons if you can get into the top of them, etc. Has anyone worked out the reason why deco classes screw with the player velocity and how can I cancel this so my project can continue?
So long, and thanks for all the fish
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Calling touch on a decoration

Post by Feralidragon »

You forgot to change the physics, use AddVelocity for pawns instead:

Code: Select all

Pawn(Other).AddVelocity(600*vect(0,0,1));
I just put Pawn(Other) since idk if Other is always a pawn or not (as AddVelocity is a pawn only function).
The thing is, the Pawn physics is constantly changing, and each one behaves differently on velocity changes, therefore there's a function called AddVelocity in pawns to do just what you want to do, and which they make the necessary checks and physics changes to actually make it work if possible at all in that pawn.

Take a look at the Pawn class implementation of this function:

Code: Select all

function AddVelocity( vector NewVelocity)
{
    if (Physics == PHYS_Walking)
        SetPhysics(PHYS_Falling);
    if ( (Velocity.Z > 380) && (NewVelocity.Z > 0) )
        NewVelocity.Z *= 0.5;
    Velocity += NewVelocity;
}
"Why not just making that in the code" you may ask, and the answer: is safer, since each pawn behaves differently and thus they have different implementations of AddVelocity (for instance you wouldn't want a team cannon to be thrown out, would you? :lol2: ).
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Calling touch on a decoration

Post by JackGriffin »

Thanks for the lesson Sensei. As usual you were right on and nailed it, it works now. As a follow up question I'd like to still be able to bump this thing around a little bit to position it correctly once it's thrown down (or move it away if you are are on the opposing team) and only trigger the fling if you are hopping onto it. What sort of check would I use to allow this? Since the whole thing is called on bump my physics is already walking and I've tried checks for velocity.z to no good use.
Should I create a second collision area like this (via a spawned trigger at (1,1,1) away from the mesh):
awesomePSskillezYo.jpg
awesomePSskillezYo.jpg (60.23 KiB) Viewed 2109 times
to account for the various PHYS states or do you see an easier code check that would better work? I've tried what I know already and nothing works right once collision with the mesh has occurred.
So long, and thanks for all the fish
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Calling touch on a decoration

Post by Feralidragon »

Well, just checked in the code of Pawn and on "landing" the "Landed" event is called, and curiously it setups a var called bJustLanded to True.

So, perhaps, as first tryout (since I am not really sure), you could try to check if bJustLanded in the pawn is True.
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Calling touch on a decoration

Post by JackGriffin »

BTW just as a follow up to this Ferali I'd like to add some testing results from the PostalBabes mod too. In it I spawn a rotating disk for the dancers to stand on. They aren't really standing on it, they just spawn and rotate like they are. I was testing it by spawning just the platform into a test map and it did fine and rotated as it should. If I jumped onto it, I rotated and everything seemed fine. However when I went to jump off it launched me into the sky :lol2: and I was able to repeat this over and over. There is something about the decorations collision that's probably native and it's just goofy about adding z velocity.
So long, and thanks for all the fish
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Calling touch on a decoration

Post by Feralidragon »

JackGriffin wrote:There is something about the decorations collision that's probably native and it's just goofy about adding z velocity.
Not that I am aware of. :noidea
They can just move, be kicked, pushed, and etc under some circumstances as you know, so probably your rotating platform did some move to launch you like a catapult projectile rofl
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Calling touch on a decoration

Post by JackGriffin »

That's the thing, lol. Here's the entire code for the class:

Code: Select all

class MH2Table1 extends StudMetal;

defaultproperties
{
	DrawType=DT_Mesh
   Mesh=Mesh'PBStage'
   bStatic=False
   Physics=PHYS_Rotating
   Velocity=(X=0.00,Y=0.00,Z=5000.00),
   DrawScale=1.0
   bFixedRotationDir=True
   RotationRate=(Pitch=0,Yaw=5000,Roll=0),
   CollisionRadius=30.00000
   CollisionHeight=4.00000
   bCollideWhenPlacing=True
   bCollideActors=True
   bCollideWorld=True
   bBlockActors=True
   bBlockPlayers=True
}
For some reason if you make a deco rotate it picks up some strange tendencies. I've seen this though in MH deco stuff too though. Yeah it's weird lol.

EDIT:
I'm a retard. Yeah, go ahead and make fun of me, I completely missed that until I just pasted it into here.
Image

Where did that come from? I have no idea :/ I must have done that way back in MH coding because I've used this class setup for several years. It's all my coding though so I take the blame.
So long, and thanks for all the fish
Post Reply