Making a Pickup Bounce

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
LOZ_98
Posts: 67
Joined: Thu Mar 22, 2018 7:46 pm
Graphics Processor: nVidia (Modern GZDoom)

Making a Pickup Bounce

Post by LOZ_98 »

It seems like all Bounce flags and properties affect only missiles / projectiles, Is there a way to do it with Pickups ?
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Making a Pickup Bounce

Post by Matt »

What kind of bounce specifically do you want? (and why is a pickup bouncing around anyway?)

There might be a way to fake it with A_ChangeVelocity and CheckMove.
User avatar
LOZ_98
Posts: 67
Joined: Thu Mar 22, 2018 7:46 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Making a Pickup Bounce

Post by LOZ_98 »

It's a pickup that the player drops after he gets damaged, I want it to bounce after falling, I want the bounce strength to change depending on how fast the item falls, what does CheckMove do?
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Making a Pickup Bounce

Post by Matt »

CheckMove checks if an actor can move to a given set of XY coordinates, letting you check whether there's a blocking actor or line. I mention it in case you needed horizontal bouncing.

For vertical bouncing off the floor only it can be much simpler:

Code: Select all

override void Tick(){
    // if it's on the ground and moving downwards,
    // make it move upwards instead but not as fast
    if(
        vel.z<0 &&
        pos.z<=floorz
    ){
        vel.z=-vel.z*bouncefactor;
    }
    // do all the other ticky stuff
    super.Tick();
} 

Return to “Scripting”