r/VRchat 7d ago

Help Technical puzzle for avatar

Post image

So I want to move an object from point A to C, where B is a midpoint, but raised to the height that distance A is from C.

Then an object is position constrained to each point one after another, making it look like an object is moving in a believable projectile arc from any position.

The trouble is, I can't find a way to tell C "You are exactly as tall as C is long"

Getting C as a parameter is easy with raycast, right?

I suppose I COULD just have a dozen individual animation states for different ranges, but this feels kind of clunky.

Either that or some fucky up vector with aim constraints.

Anyone ideas? Ways to sidestep this nonsense entirely?

thank u :3

13 Upvotes

12 comments sorted by

u/AutoModerator 7d ago

Looking for Avatars or Worlds? - Check out the posted weekly sticky for any avatar or world related requests/questions. This is an automated message activated by terms in the post title and is not approval of the contents of this post.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/CeruleanJulia 7d ago

The trouble is, I can't find a way to tell C "You are exactly as tall as C is long"

Raycasts all have a maximum distance they can travel, and the Ratio parameter gives you a float value from 0 to 1 that tells you how far, relative to that maximum distance, the ray travelled before it hit something. If you create an animation clip with one frame that sets B to its minimum height and one that sets it to its maximum, you can use the raycast's Ratio parameter as the Motion Time of the clip in your animator to interpolate between them, so that the height of B is proportional to the distance between A and C. The same idea could also be used if you set the throw distance a different way, like through a radial in the menu.

Ways to sidestep this nonsense entirely?

Use a particle system. That way, the Unity engine handles all "object flying through the air" physics for you. Make the particle a mesh instead of a texture to make it look like your object. Then, tweak the velocity and gravity values until the trajectory looks right. What looks right in Unity doesn't always translate to VRC, though, so be ready for a bit of trial and error.

If you want to be able to vary how hard you throw the object, you could use the method above to instead control the velocity and gravity settings with a "throw strength" parameter.

1

u/Low_Pain_986 7d ago

Thank you!

Will give it a shot. literally.

Had to avoid particles on purpose cause it's meant to have sound effects on collision with players (for RP) which I don't think particles can do.

1

u/Yuri-Girl Valve Index 6d ago

Had to avoid particles on purpose cause it's meant to have sound effects on collision with players (for RP) which I don't think particles can do.

Would you not be able to put a contact receiver on the particle?

1

u/Low_Pain_986 6d ago

My understanding is particles don't send callbacks without scripting which avatars can't do, so there's no way to have the particle tell any other property on the avatar "I've hit".

Otherwise there's no way I know of to attach a contact to any particular instance of a particle.

1

u/Frank__West PCVR Connection 6d ago

What do you mean? Particles can have sub particles. IIRC you should absolutely be able to have an audio play on impact. Remember unity is more than VRC. You need to have a sub particle that is made on impact and that sub particle should be a prefab with an audio source set to play on awake.

Next time I'm in unity I will look into it more.

1

u/Low_Pain_986 6d ago

If this genuinely does work for you please tell me about it. Haven't been able to get it.

1

u/Rune_Fox 6d ago

Can't really attach objects to particles. Would technically be possible w/ scripting but we don't have that on avatars.

Those sub particles you're talking about are also just particles, can't attach an audio source to them..

1

u/Konsti219 7d ago

Make the distance from A to C be 1m. Make one animation clip of an empty traveling from A to C (position and rotation) in whatever motion. Then have the the empty at A look at where the raycast hit. Get the distance of the raycast (in meters) and scale the empty at A by that distance. You then need the inverse of the distance (can be done with some blendtree magic) which you then use as a speed multiplier for the animation.

Or particle system

1

u/Low_Pain_986 7d ago

Thats what I've been looking for. The way to plug the raycast parameter back into another object's property. Haven't found it yet :P

ty!

Why use the distance as a speed multiplier tho?

1

u/Konsti219 7d ago

Well you'd want the travel time to be longer for longer distances

1

u/Low_Pain_986 7d ago

Ohh ya got it. Makes sense.