Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / VR collision voes

Author
Message
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 24th May 2019 06:15
I'm working on an endless runner in VR, but the intermixing of real-life and artificial movement seem to have screwed things up.

AGKVR gives me these values for the players position:



I can use these to lock the players Z movement to the general Z direction:



So I can use this to run directly forward:



However, I also need to swing my Touch controllers to hit in-game objects. And the swinging of my hands and the artificial Z movement doesn't seem to mix well. Both work pretty well separately, but together, the hitting just seems weird, and sometimes it doesn't even register.

In an earlier version, I actually had the player standing still, but simulated a movement by offsetting the floor texture and moving the objects in negative Z direction. And hitting stuff worked then, and it just felt good. It was the core of why I believed in this game.

I could revert to my earlier fake-locomotion build, but even if it's a quite fun way of doing things, it limits my level design a great deal. So is there any stuff I could try out to get my collision working?
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 24th May 2019 19:47
do you have any code for the part that is doing the hands?
are you using the core physics system? it doesn't really like being moved around via non-physics code, you can raycast from the hands to detect objects and create your own hit effect though
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 24th May 2019 20:05 Edited at: 24th May 2019 20:06
Yeah, I'm using core physics. Raycasting might be the solution. Never done that before but "how hard can it be"? Something like this:

IF HITTING STUFF DETECTED BY RAYCAST:
-----STORE DIRECTION AND SPEED OF HIT
-----USE THIS TO PUSH STUFF

Here's the code for the drumsticks I use to hit stuff:
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 25th May 2019 12:04 Edited at: 25th May 2019 12:11
i think you need to check for all contacts rather than just the first, the example shows it like this

though i'm pretty sure this actually ignores the first contact so you should combine it with yours until you get a valid result.

raycasting is very easy in AppGameKit, just store your ball position, move it in the desired direction you want to ray cast to (in this case probably reverse velocity to see if we went through anything) then store / ray cast using the new position and the stored, then reset the position of the ball
and you can combine both objects velocities together to make a fake impact as needed (i.e. a ball moving 0,1,0 (x,y,z) hitting an object moving 1,-2,0 makes the ball velocity become 1,-1,0 -. it bounces off at 1/2 the speed it was travelling in the y due to it's own previous y momentum trying to still move forward and the same speed as the impact in the x because it had no previous x momentum, while z is unaffected as neither have any z momentum)
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 26th May 2019 08:35
But raycasting requires physic objects. So even though I want to code the collision myself, the moment the objects make contact it will trigger the natural collision. Am I missing something?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 26th May 2019 09:50 Edited at: 26th May 2019 09:52
raycasting doesn't require physics objects but small's method does

the easiest method ive found for raycasting is to attach an invisible object where you want to raycast
ie might be a sphere at the end of the drumsticks. then I use this function to determine if theres a hit
I pass the sphere object and it will return the id of the object hit. you could modifiy it so it only checks
if the drum has a hit. you have to setobjectcollision(sphere,0) and if you don't modify so it only checks
the drum you will have to setobjectcollision(drumstick,0)
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 26th May 2019 17:25
Oh ... it works. So much thanks!

Login to post a reply

Server time is: 2024-04-19 19:14:19
Your offset time is: 2024-04-19 19:14:19