SteamVR

SteamVR

SteamVR Workshop
Customize your SteamVR experience by finding new backgrounds, 3D environments, controllers and base station models.
Learn More
soontekk 1 6 Mar, 2019 @ 5:50pm
Floatable water ?
When visiting the London Bridge map i noticed you can throw stuff in the Thames and it will float and be taken by the current.
How hard would it be for me to add that kind of functionality to my map with the river as a main thing ?
Would love to throw stuff in there and have it at least float.
< >
Showing 1-12 of 12 comments
Praxeos1 4 6 Mar, 2019 @ 6:50pm 
Here's Rectus discussing the buoyancy in his beach environment. To use the code, you would need to ensure that only the water is below 0 on the Z axis:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/comments/735164875
Cargo Cult  [developer] 10 6 Mar, 2019 @ 6:57pm 
It's a terrible, terrible hack - it's done with a large trigger_push in a block just under the surface of the water.

Spawnflags: 'Everything (not including physics debris' checked in addition to the defaults.

Push Direction (Pitch Yaw Roll): -88, 180, 0. In other words, not quite straight up, which would be -90 - this gives the effect of a current in the river. The yaw will give you a rough direction for things to float in.

Speed of Push: 65 - although I remember having to tweak this very carefully so that things would neither sink nor catapult themselves far into the sky. You'll likely need to adjust this for your own map.

It looks like the water splashes are done with trigger_multiples calling a script OnStartTouch, which then spawns a particle system at the appropriate location.

As I said, very hacky. It's amazing it works at all...
Cargo Cult  [developer] 10 6 Mar, 2019 @ 7:05pm 
Re: the water splash - there's a copy of the script in this asset pack:

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1449922161

Create a logic_script named something like 'water_splash_script', with 'Misc : Entity Scripts' set to 'water_splash'.

Create a trigger_multiple as a big block under the water's surface, similar to the trigger_push.

Spawnflags: 'Clients' unchecked, 'Physics Objects' checked.
Outputs: OnStartTouch, water_splash_script, CallScriptFunction, WaterSplashStartTouch. Delay of zero, 'Fire once only' left unchecked.

In theory at least, that should be it!
Praxeos1 4 6 Mar, 2019 @ 9:01pm 
Cool! Thanks, Cargo Cult! I was able to make both work, but I doubt any combination of values would make the trigger_push a useful option for the tiny little pool of water in my test map. At a push speed of 65, the beach ball was furiously swimming laps. Nonetheless, it would probably work well in Soontekk's flowing river.
Rectus 13 7 Mar, 2019 @ 1:23am 
If you want to use my script, it's available here: https://github.com/Rectus/destinations_range/blob/master/scripts/vscripts/beach/map_scripts/beach.lua

The water level is global for the map, but can be changed by setting WATER_LEVEL to a differnt value.
soontekk 1 7 Mar, 2019 @ 3:04am 
Hey guys, wow! Thank you for all the input. I would be happy if things wouldn't fall through or bounce off my river. I'll try the suggestions. Thanks a lot !
Praxeos1 4 25 Mar, 2019 @ 12:44pm 
Cargo Cult, Is it possible to obtain the actual water_splash.lua script from the Summit Pavilion, or is that secret stuff? I'm a complete beginner with scripting, but I've been learning by looking at and editing other people's scripts. While most of my edits are pretty basic (e.g. pointing to my own particles or sounds), I occasionally surprise myself by succeeding with some fairly substantial changes. My interest here is figuring out how to attach the particles to the activator. I have examples from Rectus for attaching the particles to an entity using its own script, but I don't know how to use a trigger's script to attach the particles to the activator. I tried using "activator" and "!activator" as handles in my own attempts, but without success. Of course, I may have just been bungling the rest of the function. If I play with it enough, I can probably isolate the particle-attachment lines from Rectus's beach map script, but I'd also like to be able to do it on the trigger entity level.
Cargo Cult  [developer] 10 25 Mar, 2019 @ 2:04pm 
Here you go - looks like 'local object = trigger.activator' is the important stuff.

--[[ Water splash ]] print( "Water splash!" ) function Activate() print("Activate!\n"); ListenToGameEvent( "player_spawn", OnPlayerSpawned, nil ) end -- Global Variables local playerTable = {} -- List of players in the map --------------------------------------------------------------------------- -- Precache --------------------------------------------------------------------------- function Precache( context ) PrecacheParticle( "particles/water_splash_1.vpcf", context ) end -------------------------------------------------------------------------------- -- Events -------------------------------------------------------------------------------- function OnPlayerSpawned( eventInfo ) --print("PlayerSpawned!") local player = GetPlayerFromUserID( eventInfo.userid ) --Add player to the player list table.insert( playerTable, player ) end function WaterSplashStartTouch( trigger ) --print("Object has entered water splash trigger") local object = trigger.activator local location = object:GetAbsOrigin() local model = object:GetModelName() local effectsTable = { origin = location, targetname = "splash_effects", start_active = "1", effect_name = "particles/water_splash_1.vpcf" } local splashEffects = SpawnEntityFromTableSynchronous( "info_particle_system", effectsTable ) splashEffects:Attribute_SetIntValue("effectsID", 1) local playerEntity = playerTable[1] if playerEntity ~= nil then playerEntity:SetContextThink( "RemoveSplashEffects", function() return UTIL_Remove(splashEffects) end, 2 ) end end
Praxeos1 4 25 Mar, 2019 @ 3:23pm 
Perfect! Thanks!
Praxeos1 4 25 Mar, 2019 @ 6:41pm 
I was able to combine elements of this with elements of Rectus's beach script. I noticed that the splash was often spawning above the water level, so I created a new variable at the beginning of the script and called it, "water_level." I set it equal to the z coordinate of the top of the water. Then, I changed the variable, "location," from the absolute origin of the object to the following from Rectus's script:

local location = Vector(object:GetCenter().x, object:GetCenter().y, water_level)

I also added a line for the SoundEvent and pointed everything to my own particles/sounds.

It all works great! I may try to figure out how to incorporate Rectus's use of a second particle (ripple only) for small bounces in the water.

soontekk - I think this would be perfect for your map.
soontekk 1 25 Mar, 2019 @ 11:06pm 
Awesome stuff guys !
Praxeos1 4 26 Mar, 2019 @ 4:13pm 
I cobbled together Rectus's and Cargo Cult's scripts and probably made a cringeworthy Frankenstein's monster of it, but I learned a lot and it actually does what I intended. The ripples consistently appear on the surface of the water, and I managed to incorporate the dual particle options (splash/ripple combo for fast, ripple for slow) from Rectus's beach script. I placed the push trigger and splash trigger at roughly the same level about 4-5 inches below the water. That way, the props bounce off the splash trigger and create ripples when they touch again. the effect was pretty good. At some point, I'll try to figure out how to convert the physics from the beach script for use with a trigger. That should keep me busy for a while. Anyway, since this works, I thought I'd leave it here for posterity. All credit goes to Rectus and Cargo Cult for whatever I got right, and the blame is all mine for whatever I mangled. Please, feel free to make corrections.

--[[ Water splash ]] print( "Water splash!" ) function Activate() print("Activate!\n"); ListenToGameEvent( "player_spawn", OnPlayerSpawned, nil ) end -- Global Variables local playerTable = {} -- List of players in the map local SPLASH_MIN_SPEED = 80 local RIPPLE_MIN_SPEED = 20 local SPLASH_INTERVAL = 0.5 --Set water_level to the z coordinate of the water surface in the map. local water_level = 13.625 local splashEnts = {} --------------------------------------------------------------------------- -- Precache --------------------------------------------------------------------------- function Precache(context) PrecacheParticle("particles/single_splash1_prax.vpcf", context) PrecacheParticle("particles/single_ripple1_prax.vpcf", context) PrecacheSoundFile("soundevents_addon.vsndevts", context) end -------------------------------------------------------------------------------- -- Events -------------------------------------------------------------------------------- function OnPlayerSpawned( eventInfo ) --print("PlayerSpawned!") local player = GetPlayerFromUserID( eventInfo.userid ) --Add player to the player list table.insert( playerTable, player ) end function WaterSplashStartTouch( trigger ) --print("Object has entered water splash trigger") local object = trigger.activator local velocity = GetPhysVelocity(object) local speed = velocity:Length() local model = object:GetModelName() local splash if speed > RIPPLE_MIN_SPEED then if splashEnts[object] == nil or (splashEnts[object] + SPLASH_INTERVAL) < Time() then splashEnts[object] = Time() local splash local location = Vector(object:GetCenter().x, object:GetCenter().y, water_level) if speed > SPLASH_MIN_SPEED then StartSoundEventFromPosition("splash1a", location) splash = ParticleManager:CreateParticle("particles/single_splash1_prax.vpcf", PATTACH_CUSTOMORIGIN, nil) else splash = ParticleManager:CreateParticle("particles/single_ripple1_prax.vpcf", PATTACH_CUSTOMORIGIN, nil) end ParticleManager:SetParticleControl(splash, 0, location) end end end
< >
Showing 1-12 of 12 comments
Per page: 1530 50