|
hello everyone here's my script: this is the buScript.around script: and this is what i get: Link as you can see the rotation is very jumpy if you can help me solve it ill be very happy
(comments are locked)
|
|
I guess the problem is the "if-else if-else". _turn will be 0 only when direction is exactly 0.3. If I understood the logic correctly the "else-if" should be else if(direction < -0.3f) is seems to work but it makes a different bug it seems to prevent them from rotating 180 im using my mouse to tell them where to go if i click behind them they dont move.....
Jan 05 '12 at 06:56 PM
dorpeleg
You could rotate using quaternions. Eg: var targetRotation = Quaternion.LookRotation(dir); myTransform.rotation = Quaternion.RotateTowards(myTransform.rotation, targetRotation, Time.deltaTime * rotationSpeed);
Jan 05 '12 at 07:34 PM
luizgpa
its even worse now my guys don't move forward and rotating his whole body towards the point
Jan 05 '12 at 08:11 PM
dorpeleg
adding the "-" plus a small change fixd it! here the working code if(direction > 0.05f) { _turn = 1; } else if(direction < -0.05f) { _turn = -1; } else { _turn = 0; }
Jan 07 '12 at 05:26 PM
dorpeleg
(comments are locked)
|
|
Try using dot product with the forward vector to determine if you need to rotate and then use the right vector to figure out what direction like: Also you can consider using the magnitude of the vector between the object and target's positions instead of your around function because it will it will describe radial distance whereas the around function basically does a bounding box test as it is. Unless of course this is your intention. i triad it like this dir = (pos - myTransform.position).normalized; and the original bug is back... so no good
Jan 05 '12 at 08:05 PM
dorpeleg
(comments are locked)
|

Perhaps try rotating a dummy object and use
mathf.Clampto restrict rotation range, then dump the result intomyTransform.rotation?can you explain a bit further? its looks like what i did with the "around" is similar to the clamp