Unity3D Virtual Reality Physics - Baseball / Cricket / Tennis - SteamVR

Поделиться
HTML-код
  • Опубликовано: 13 янв 2025

Комментарии • 57

  • @na__cho
    @na__cho 6 лет назад +1

    This is a great video!
    From what I understand, steamVR is modifiying the position of the controllers using the transform, which isn't changing the velocity of the rigidbody attached to it, that's the reason the follower has a rigidbody and is the one that actually creates the collision that moves the ball

    • @PeterSvP
      @PeterSvP 6 лет назад

      Yes. This is the reason. SteamVR only uses the Transform. You can either use invisible follower that updates its transform.position but sets a velocity vector, or use RigidBody.MovePosition/MoiveRotation directly from FixedUpdate to follow. This way PhysX will track and manage velocity, but for best resoults, Physics rigidbody must be separate from the rendered graphical model

  • @EstanislaoGonzalezBerlin
    @EstanislaoGonzalezBerlin 2 года назад +3

    in 2022.1.23f1 for the oculus2 I had the problem that the follower was behaving erratically (it was jumping between two positions in front and behind the racket). Apparently the 100 in sensitivity was too much and it overshoot. Setting it a bit lower (90) actually solved my problem.
    Thanks Jason!

  • @alsantour8835
    @alsantour8835 6 лет назад +4

    Hi Jason, trying to implement this solution on my game without success (MiniGolf VR on Oculus). With the deleted line at 9:10 the capsule follower spin wildly on the first collision, I dont see how line 20 would have set the rotation since it is setting it to its own rotation. If I bring back line 25 the followers seem to works (or at least move) fine, but now when I swing the club at the ball with a little bit of speed it passes through the ball. Ball collision set to "Continuous" while CapsuleFollowers are "Continuous Dynamic" my fixed timestep is 0.01111 .... I also dont understand how in your video the Bat Capsule Follower does not have a capsule collider....how is it colliding with the ball? I dont see you adding it back at any point, but when you demo it in the beginning it worked!!! Assuming that somehow these capsule colliders did exist at the beginning of the video, does the "material" on these matter? Im at a loss! Please advise if/when possible?

    • @ralpholiver2889
      @ralpholiver2889 5 лет назад

      Exactly where I'm stuck in, and exactly my doubts. Ever figured it out?

    • @vkapoor69
      @vkapoor69 2 года назад

      Did you ever find a solution?

    • @alsantour8835
      @alsantour8835 2 года назад

      To be honest that is such a long time ago I don't exactly remember how I fixed it... I did end up with a solution, (cuz I published that game) ... I think what I did (if I'm not mistaken) is I broke the club speed into 3 brackets, at the low speed bracket I used just unity's vanilla collision detection, if the club is moving at medium speed I use the method in this video, if the club is moving at high speed I used a third method...

    • @alsantour8835
      @alsantour8835 2 года назад

      The third method is to simple keep track of the transform of a bunch of specific points on the face of the club, I record the last transform then on the next fixed update I would make a line from the points last position to the points current position, then check if that line intersects with the balls mesh... Kind of messy, but the only way I got it to work... Bare in mind I was also working in Unity 2018 so physics/collisons may have changed or gotten better... Hope this helps

    • @vkapoor69
      @vkapoor69 2 года назад

      ​@@alsantour8835 Thanks. It's a great idea to use multiple methods based on speed. Per Unity documentation "Collider-less Rigidbodies will simply pass through each other during physics simulation." So I don't understand why Jason deleted the capsule collider. I put the colliders back but I still can't get the ball to bounce back from the bat using this method.

  • @tadhgivors
    @tadhgivors 3 года назад

    Great video really helped my college project move along with this, was almost gonna drop the baseball bit

    • @vkapoor69
      @vkapoor69 2 года назад

      It doesn't work at all for me. The ball just passes through the bat. Did you have to make any modifications to get it to work?

    • @tadhgivors
      @tadhgivors 2 года назад

      I did make sure it collides from up close first and tweaked some of the mass settings, but otherwise no I didn't change much in it, maybe make sure continuous colliding is on and mess with the size of the colliders. Although I'm not sure I'll try look at my own again and get back to you.

    • @vkapoor69
      @vkapoor69 2 года назад

      @@tadhgivors Thank you, that would be awesome! I tried continuous dynamic and continuous speculative but it didn't work. I got tired of it and went back to refining the approach where I calculate the force and direction of the ball based on collision direction and speed. But I really want to see this one working as well.

    • @vkapoor69
      @vkapoor69 2 года назад

      @@tadhgivors I was wondering how to check if it collides since there is no OnCollision function in the code as he took out the colliders.

    • @tadhgivors
      @tadhgivors 2 года назад

      @@vkapoor69 when debugging I just had the ball have a tag to check if the bat hits it to set off a oncollision event and from there make sure the hit is being registered in the console.

  • @xressentials
    @xressentials 3 года назад

    Thanks @JasonWeimann Works, had to force rotation on the V.2020.3.17 for the HP Reverb G2 WMR and Unity, trying to see how to ensure ball doesn't go beyond collider as it seems to go through . I used one Cube, flattened it to put on a racket object. If u have answer to that, that would be great if not will experiment as I doubt you may see this comment due to the amount of comments you get on all your other videos.

  • @michon96
    @michon96 Год назад

    Hi Sir Jason, I know this is an old video but will it still hold up to today's (2023) VR physics? just wondering.

  • @ahannam4631
    @ahannam4631 7 лет назад +1

    Thanks for posting this!

  • @dudemanphat
    @dudemanphat 7 лет назад

    This is awesome, thanks for the video man.

  • @CrossPathOfficial
    @CrossPathOfficial Год назад

    How can I do this but with my hand?

  • @just5two163
    @just5two163 3 года назад +2

    Doesn't work for me. The followers are in random places after one swing.

  • @tszchingchiang874
    @tszchingchiang874 2 года назад

    Applying this with a VIVE tracker. The tracker is installed on the left foot which we will use it to kick the football. Originally, the football will not gain velocity when the foot kick the ball. It seems that the tracker do not have a velocity and can't transfer it to the football. Using the same technique in this video it is working as expected. Thanks a lot! BTW, you may encounter some problems in this video. If so, you can look at other comments for answers.

  • @krabesandwich
    @krabesandwich 7 лет назад +1

    Hi! This is great! Would this work with a golf club as well? I’m trying to make a VR golf project. I’m wondering since you would only want to hit the ball with the head of the club. Thanks for all the great tutorials!

    • @Unity3dCollege
      @Unity3dCollege  7 лет назад +1

      Yep it would definitely work, I actually did that in a game, just made the collider a box instead of spheres and only did 1 instead of a bunch.

    • @krabesandwich
      @krabesandwich 7 лет назад

      Hey thanks, I'm trying to add haptics on collision with the ball. Do I add that to the bat or to the Bat follower script?

    • @xressentials
      @xressentials 3 года назад

      @@Unity3dCollege did same worked a bunch, but now trying to see how to ensure ball doesn't go through the rigid body as it does that at times.

  • @tris0913
    @tris0913 3 года назад +1

    good tutorial. but it doesnt seem to work anymore

  • @notavalible8212
    @notavalible8212 6 лет назад +1

    Hey there! My ball passes through my bat when I swing fast, i have done exactly as you said in the tutorial, still not working. How can I solve this?

    • @NorthernlionLP
      @NorthernlionLP 5 лет назад +1

      Did you ever find a fix to this?

    • @sicemshooters
      @sicemshooters 5 лет назад +1

      Hey guys kinda late but I figured out that in the bat rigidbody, set the collision to continuous dynamic. That allows high speed collision with rigidbodies

    • @harishganesan3575
      @harishganesan3575 4 года назад

      Probably it phased through the bat. /s

  • @mohibqureshi1161
    @mohibqureshi1161 7 лет назад +1

    Hello sir ! i making VR game like this, but if the ball is coming towards you with some good pace and you swing the bat the speed then it misses but i can still hear the sound of collision. in video u are hitting the ball which is not moving. so what is the solution to my problem? can we even achieve good enough collision or not?? ( Remember if i don't move bat quickly, moving ball collides properly).

    • @NorthernlionLP
      @NorthernlionLP 5 лет назад

      Did you ever find a fix to this?

    • @joewood6029
      @joewood6029 2 года назад

      I know its crazy late but i would recommend using dynamic speculative on your rigidbody collision detection mode

  • @maycodes
    @maycodes 4 года назад

    This is awesome.

  • @shomz
    @shomz 6 лет назад

    Oh wow, are you saying that Unity's physics engine doesn't calculate angular momentum upon collision? Meaning, the both sides of an unbalanced seesaw would apply equal force to the people sitting on them. How could they get away with this for so many years? Thank you (I will have to test this myself tomorrow)

    • @NorthernlionLP
      @NorthernlionLP 5 лет назад

      It does! But baseball bats are more weighted towards the bottom rather than top, that's why he used those different rigidbodies.

  • @gianlucamonti8041
    @gianlucamonti8041 7 лет назад

    great! how can I use it for a tennis game? since the collision area in this case is flat, and I need to orient the ball in the right direction, capsule is the right choice? thanks

    • @TheSubsonicOne
      @TheSubsonicOne 6 лет назад

      wouldn't you use a mesh collider, but same deal?

  • @Maniolnba
    @Maniolnba 7 лет назад

    Hey, It should work same way for GearVR?

  • @Killer_Nads
    @Killer_Nads 7 лет назад

    Thanks thats excellent! I guess we could also use a similar approach for VR melee weapons (but with less colliders)? :D

    • @Unity3dCollege
      @Unity3dCollege  7 лет назад +2

      Yea it'd work great for weapons. Could also add a modifier to the points for a 'sweet spot' that does extra damage.

    • @jimmyaggalut1828
      @jimmyaggalut1828 6 лет назад

      Can you create a tutorial about Bigbang theory??

  • @russty938
    @russty938 7 лет назад

    Thanks, this vid really helped me out! However when the followers are instantiated the rotation does not seem to update. Any idea of what could be wrong?

    • @Unity3dCollege
      @Unity3dCollege  7 лет назад

      Hard to say w/o looking at the code, but they should orient properly. If they're always offset the same amount it may be easy to just add an additional rotation into their OnEnable to fix it.

    • @gianlucamonti8041
      @gianlucamonti8041 7 лет назад +1

      try to "force" it: _rigidbody.transform.rotation = transform.rotation; --> _rigidbody.transform.rotation = _batFollower.transform.rotation; : for me it works

    • @xressentials
      @xressentials 3 года назад

      @@gianlucamonti8041 this worked, thank you :)

  • @3dfuture.ledcanvas
    @3dfuture.ledcanvas 7 лет назад

    followers are getting bigger! ^^

  • @did3d523
    @did3d523 6 лет назад

    download demo dont work no bat...

    • @Unity3dCollege
      @Unity3dCollege  6 лет назад

      There was a link to grab the bat below the source (not one I own so can't redistribute it myself).

    • @did3d523
      @did3d523 6 лет назад

      not the only mistack in script downloaded a line is missing
      the line where fallow object copy the rotation of target object (you can see that you delete it in 9min:35sec video)
      I repair that now it work well
      I notice in your script a system to make hand and harm kinetix , I looking for a system (simple) to make Legg link to the tracker on shoes to the head set.
      sorry for my bad english.
      thanks

    • @blaccy5991
      @blaccy5991 5 лет назад

      @@did3d523 what

  • @martinrupertbulquerin228
    @martinrupertbulquerin228 7 лет назад

    Cool.. can you create a tutorial using a character or player that is swinging the bat when you touch or swipe the screen?