You are viewing our Forum Archives. To view or take place in current topics click here.

Unity - Need help with Raycasting and moveTowards.Posted:

BPM
  • Christmas!
Status: Online
Joined: Sep 12, 20107 Year Member
Posts: 7,001
Reputation Power: 508
So essentially this is what I want to replicate currently. Exploded view.



At the moment I am trying to attach a rayCast script to to a FP camera and have an object smoothly animate from a 'complete object to an 'explded view' with all the parts going to a target position once clicked.
I have managed to create a script that will move each part to its target position smoothly using Vector3.moveTowards, but it happens automatically. I need it to do it on click. This is where I am having problems. I have no idea how to. When I almost get it working on click, moveTowards doesn't work. Parts just go from point A to point B.

Unable to post code at the moment as I haven't the projects files on me at the moment, but looking for suggestions or maybe Ppseudocode examples. Hopefully trying to get a script setup that I can apply it to many objects and not just the one.

Any help would be appreciated



Last edited by BPM ; edited 1 time in total
#2. Posted:
FourStar
  • 2 Million
Status: Offline
Joined: Dec 15, 20125 Year Member
Posts: 769
Reputation Power: 65
Im not too familiar with Unity as I favour Unreal Engine but if im understanding correctly this could help - [ Register or Signin to view external links. ]

Make sure to post in the Unity Community support forums - [ Register or Signin to view external links. ]
#3. Posted:
BPM
  • E3 2016
Status: Online
Joined: Sep 12, 20107 Year Member
Posts: 7,001
Reputation Power: 508
FourStar wroteIm not too familiar with Unity as I favour Unreal Engine but if im understanding correctly this could help - [ Register or Signin to view external links. ]

Make sure to post in the Unity Community support forums - [ Register or Signin to view external links. ]


Thanks but I Should have mentioned Im trying to avoid Animation, pushing for a reuseable script for essentially 'any model'
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.