Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411507 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 26, 2024, 01:51:38 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Unity 3D Javascript help!
Pages: [1]
Print
Author Topic: Unity 3D Javascript help!  (Read 956 times)
RidiculousJohn
Level 0
**



View Profile
« on: July 24, 2014, 10:52:29 AM »

So I want to make a beat em up of sorts featuring a top down camera movement.

The key things is that I want two characters linked together and each use one joystick. I was thinking of using a sphere trigger to check if they are in there limits and be pulled back into the sphere if not. I want the sphere to always be in the center of those two positions so it must update its location. Then for animation I want to make sure the players face the direction the stick points in and stop when the stick is at 0,0.

I looked up some trigonometry but I would love a more well studied person's perspective. THANKS!
Logged
zacaj
Level 3
***


void main()


View Profile WWW
« Reply #1 on: July 24, 2014, 10:53:40 AM »

to center the sphere, just move it to the average of the two positions
Logged

My twitter: @zacaj_

Quote from: mcc
Well let's just take a look at this "getting started" page and see--
Quote
Download and install cmake
Noooooooo
RidiculousJohn
Level 0
**



View Profile
« Reply #2 on: July 24, 2014, 10:55:37 AM »

to center the sphere, just move it to the average of the two positions
I know that math but I was wondering if doing it in code would be more challenging.
Logged
Quarry
Level 10
*****


View Profile
« Reply #3 on: July 24, 2014, 01:58:08 PM »

What if you did it and then saw it for yourself
Logged
RidiculousJohn
Level 0
**



View Profile
« Reply #4 on: July 24, 2014, 06:42:00 PM »

Well gosh I'm rusty but I'll try.
Logged
BilbyCoder
Level 0
**



View Profile WWW
« Reply #5 on: July 27, 2014, 05:09:13 AM »

I'd think it might be easier to get the distance between the two characters, make sure it's <= the distance you allow them to be apart.  If it's greater than the distance you need, move them back towards each other by half the difference using Vector3.MoveTowards.  The Unity Vector3 class does all the trig for you.

Saves having a trigger in the scene which seems a little overkill for what you need, unless you are using it for something else already.
Logged

Programmer
Binary Sprite
www.binarysprite.net
RidiculousJohn
Level 0
**



View Profile
« Reply #6 on: July 29, 2014, 12:31:06 AM »

I'd think it might be easier to get the distance between the two characters, make sure it's <= the distance you allow them to be apart.  If it's greater than the distance you need, move them back towards each other by half the difference using Vector3.MoveTowards.  The Unity Vector3 class does all the trig for you.

Saves having a trigger in the scene which seems a little overkill for what you need, unless you are using it for something else already.
wll I want smooth animations and movement. Nothing jarring and I need something to constantly check. Triggers usually do fine.
Logged
BilbyCoder
Level 0
**



View Profile WWW
« Reply #7 on: July 30, 2014, 02:30:44 AM »

It depends.  Do you want them to be able to pull apart from each other beyond the limits you've created and have them visibly pulled back together, in which case you will need animations and smoothing.

If you just want to prevent them from ever moving too far apart, then each time they move, check the distance.  If they would move beyond the limit, reduce the movement so they remain at the limits.

Logged

Programmer
Binary Sprite
www.binarysprite.net
RidiculousJohn
Level 0
**



View Profile
« Reply #8 on: July 30, 2014, 08:47:53 AM »

It depends.  Do you want them to be able to pull apart from each other beyond the limits you've created and have them visibly pulled back together, in which case you will need animations and smoothing.

If you just want to prevent them from ever moving too far apart, then each time they move, check the distance.  If they would move beyond the limit, reduce the movement so they remain at the limits.


Well I was thinking one player if having a greater speed can drag the other. I'll take my time with this.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic